Thread overview |
---|
August 17, 2006 auto auto again | ||||
---|---|---|---|---|
| ||||
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 |
August 17, 2006 Re: auto auto again | ||||
---|---|---|---|---|
| ||||
Posted in reply to Charles | Actually a further revision , based on an archived post I think this syntax:
MyClass c = local MyClass();
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
|
August 17, 2006 Re: auto auto again | ||||
---|---|---|---|---|
| ||||
Posted in reply to Charles | 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 |
August 18, 2006 Re: auto auto again | ||||
---|---|---|---|---|
| ||||
Posted in reply to renox | > 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
|
August 19, 2006 Re: auto auto again | ||||
---|---|---|---|---|
| ||||
Posted in reply to renox | "renox" <renosky@free.fr> wrote in message news:ec2of6$2rj6$1@digitaldaemon.com... > 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 don't know why he likes that syntax. He's a big opponent of "easy-to-mess-up" syntax, and I sure can't see much of a difference between "c = MyClass()" and "c = new MyClass()". |
August 19, 2006 Re: auto auto again | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | I agree, it certainly is easy to miss. I imagine he doesn't want to introduce a new keyword for it , but renox's syntax of := I think is an elegant solution !
Jarrett Billingsley wrote:
> "renox" <renosky@free.fr> wrote in message news:ec2of6$2rj6$1@digitaldaemon.com...
>
>> 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 don't know why he likes that syntax. He's a big opponent of "easy-to-mess-up" syntax, and I sure can't see much of a difference between "c = MyClass()" and "c = new MyClass()".
>
>
|
Copyright © 1999-2021 by the D Language Foundation