digitalmars.D - auto auto again
- Charles (10/10) Aug 16 2006 Just wanted to suggest that auto ( the auto that means destroy on scope
- Charles (5/17) Aug 17 2006 Actually a further revision , based on an archived post I think this syn...
- renox (19/40) Aug 17 2006 If memory serves, Walter current view is:
- Charles (3/57) Aug 18 2006 I like that idea!
- Jarrett Billingsley (5/10) Aug 18 2006 I don't know why he likes that syntax. He's a big opponent of
- Charles (4/18) Aug 18 2006 I agree, it certainly is easy to miss. I imagine he doesn't want to
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
Aug 16 2006
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
Aug 17 2006
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
Aug 17 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
Aug 18 2006
"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()".
Aug 18 2006
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()".
Aug 18 2006