auto auto again

Charles nonone at nowhere.com
Fri Aug 18 16:10:49 PDT 2006


 > If memory serves, Walter current view is:

Oh ok, Im anxious to see that change happen then :).

 > 1) for stack variable  c := MyClass(); (of course MyClass c = MyClass();
 > would still work)
 > 2) for global variable c := new MyClass(); (of course MyClass c = new
 > MyClass(); would still work).

I like that idea!


renox wrote:
> Charles wrote:
>> Actually a further revision , based on an archived post I think this 
>> syntax:
>>
>> MyClass c = local MyClass();
> 
> If memory serves, Walter current view is:
> a) For stack variable MyClass c = MyClass(); or auto c = MyClass();
> and
> b) For global variable MyClass c = new MyClass(); or auto c = new 
> MyClass();
> 
> I'm not sure what is the benefit replacing a) by
> MyClass c = local MyClass(); or auto c = local MyClass(); for stack 
> variable?
> 
> What would be the meaning of 'MyClass c = MyClass();', the global case, 
> dropping the new? Forbiddeb? Or something else?
> 
> RenoX
> 
> PS:
> just some advertising for my own view: replacing 'auto' by a ':=' 
> operator for type deduction (I liked too much Limbo syntax probably), 
> which would make:
> 1) for stack variable  c := MyClass(); (of course MyClass c = MyClass(); 
> would still work)
> 2) for global variable c := new MyClass(); (of course MyClass c = new 
> MyClass(); would still work).
> 
> 
>> works better.  It looks good, and is very explicit.  'local' can be 
>> replaced with 'raii' , 'stack' or whatever you like.
>>
>> Charles wrote:
>>
>>> Just wanted to suggest that auto ( the auto that means destroy on 
>>> scope exit ) , be renamed to raii , or anything that eliminates the 
>>> double meaning of 'auto'.  I know auto in C was used to mean 
>>> something similar, but C has no automatic-type-deduction named auto, 
>>> and the current situation in D prevents one from doing an 
>>> auto(type-deduction) auto(destroy) declaration, as in : auto auto a = 
>>> new MyClass;
>>>
>>> Thx!  It is only an aesthetic change I know but I think it will add a 
>>> lot to the general flow of the language, as well as allow type 
>>> deduced raii variable declaration.
>>>
>>> Charlie



More information about the Digitalmars-d mailing list