auto storage class - infer or RAII?

Hasan Aljudy hasan.aljudy at gmail.com
Sun Nov 12 21:08:54 PST 2006



Sean Kelly wrote:
> That said, I do appreciate your concern about static opCall.  As a 
> somewhat bizarre suggestion that would break the consistency illustrated 
> above:
> 
>     MyClass c = new(scope) MyClass(); // scoped class
>     MyClass d = new MyClass;          // dynamic class
> 
> I don't really like this, but it would work with the existing placement 
> new syntax and doesn't require any new keywords either.

Actually that's not so bizzare at all, because "new" already accepts 
parameters.

http://digitalmars.com/d/memory.html#stackclass

With a little magic, you can achieve the same effect, using:

MyClass c = new (alloca(MyClass.classinfo.init.length)) MyClass;

Now, /that/ is bizzare. It would be very nice IMHO if there was a 
simpler way to do it, such as

var c = new(scope) MyClass;

> 
> 
> Sean



More information about the Digitalmars-d mailing list