Walter: Before you go and implement the new RAII syntax..

Chad J gamerChad at _spamIsBad_gmail.com
Wed Sep 6 22:09:16 PDT 2006


No.  The advantage of auto is that you can enforce this behaviour at the 
class declaration.
Example:

auto class Foo
{
   int member;
   this() {}
}

void main()
{
   auto Foo foo = new Foo(); // ok
   Foo bar = new Foo(); // error: reference to auto class must be auto
}

Of course, what Chris pointed out is cool from the standpoint that we 
could probably have the 'auto' keyword (or whatever may replace it) be 
in the allocator position without losing too much.

Garett Bass wrote:
> I wasn't aware of that, pretty cool!  In this case, perhaps do away with 
> the old local-scope meaning of 'auto' altogether.
> 
> Chris Nicholson-Sauls wrote:
> 
>>
>> The following works right now, and does so just fine:
>>     Foo foo = SomeFactory.newFoo(...); scope(exit) delete foo;
>>     char[] a = read(filename); scope(exit) delete a;
>>
>> -- Chris Nicholson-Sauls



More information about the Digitalmars-d mailing list