auto storage class - infer or RAII?

Jarrett Billingsley kb3ctd2 at yahoo.com
Sun Nov 12 16:14:23 PST 2006


"Sean Kelly" <sean at f4.ca> wrote in message 
news:ej87h8$10nk$1 at digitaldaemon.com...

> What is the special case here?
>
>     int i  = 5;       // scoped int
>     int* j = new int; // dynamic int
>
>     MyClass c = MyClass();     // scoped class
>     MyClass d = new MyClass(); // dynamic class

My main problem with it (besides not being able to use static opCall, which 
I do use), is that it's far, far too easy to miss.  The first time Walter 
proposed this .. "syntax," I didn't know what he was proposing until I 
looked real hard at the code for a minute or two.  If you _really_ want to 
make it obvious that it's a RAII class instance, either use a different 
keyword, or maybe even recycle the C++ way:

MyClass c(params);

Not that I'm entirely supporting that syntax, but the "Class name = new 
Class()" is such a common idiom that introducing the very-similar-looking 
"Class name = Class()" will only cause confusion. 





More information about the Digitalmars-d mailing list