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

Sean Kelly sean at f4.ca
Wed Sep 6 22:11:24 PDT 2006


Chad J wrote:
> 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
> }

This is cool in theory but I have yet to actually use this feature.  I 
simply don't see the point in re-using 'auto' in this way.

> 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.

If a keyword were retained to signify auto-destruction then I think it 
should be in place of 'new' and not attached to the variable itself. 
Reason being that it's the data that's going away, not whatever that 
variable happens to reference on scope end.


Sean



More information about the Digitalmars-d mailing list