auto storage class - infer or RAII?
JC
johnch_atms at hotmail.com
Mon Nov 13 03:03:49 PST 2006
"Walter Bright" <newshound at digitalmars.com> wrote in message
news:ej9acb$1sac$2 at digitaldaemon.com...
> Tomas Lindquist Olsen wrote:
>> *shivers* by the thought of 'var'
>
> I knew that somehow I couldn't be the only one <g>.
I don't see much wrong with 'var'. It has the nice connotation that it
represents a variable, at least.
As for RAII, just using a keyword alone doesn't seem to cut it. If
references are to be automatically deleted at the end of a scope, that
infers that a scope is actually introduced, which to me is signified by a
matching pair of curly brackets. I'd like to be able to specify the extent
of the scope, perhaps like this:
void drawBox(Rectangle rect, Colour colour) {
scope (DrawingContext dc = createDrawingContext()) {
scope (Pen pen = new Pen(colour)) {
dc.drawRectangle(pen, rect);
} // pen is freed here
} // dc is freed here
}
Used this way, 'scope' as the RAII keyword makes sense.
More information about the Digitalmars-d
mailing list