Auto syntax revisited

Fredrik Olsson peylow at gmail.com
Tue Feb 21 10:21:20 PST 2006


AgentOrange skrev:
> In article <ops5bhg5ol23k2f5 at nrage.netwin.co.nz>, Regan Heath says...
> 
>>On Mon, 20 Feb 2006 21:23:26 +0100, Fredrik Olsson <peylow at gmail.com>  
>> <snip>
>>auto a = new A(); //heap alloc, 'a' is of type reference to 'A'
>>auto a = A();     //stack alloc, destruct at scope exit, 'a' is of type  
>>reference to 'A'
>>
>>Regan
> 
> 
> are we going to lose static opCall? yikes!
> 
And the possibility of allowing non stack objects to automatically go 
out of scope in the future without changing the syntax? I do not say 
that it should be added now, all I say is that it would be good if the 
syntax allowed for it. Ones we go 1.0 much of the syntax will pretty 
much have to stay, so better be prepared :). A functionality restricted 
by the compiler is easier to fix and causes less harm than a feature 
restricted by the syntax.

Plus with: auto a = A();
It is absolutely no way to just at a glance make sure with 100% sertenty 
that a is not assigned the result of a function, instead of being 
instantiated on the stack.

// Fredrik



More information about the Digitalmars-d mailing list