digitalmars.D - Remove declaration 'auto' for RAII?
- Chris Miller (9/9) Mar 13 2006 There is a problem with auto when declaring variables!
- Jarrett Billingsley (3/12) Mar 13 2006 Sigh.. was it really necessary to start another thread about this?
- Tom (5/20) Mar 13 2006 Sorry, why to do that? I don't want to be forced to free every object ma...
- Chris Miller (6/28) Mar 14 2006 They accomplish the same thing, but perhaps scope can be used to indicat...
- Tom (9/38) Mar 14 2006 Oh I see. But to be obliged to add 'scope(exit) delete foo' after every ...
-
Stewart Gordon
(15/21)
Mar 15 2006
- Stewart Gordon (17/30) Mar 15 2006 The RAII meaning of auto came first. D programmers from pre-0.137 days
There is a problem with auto when declaring variables! Not only does it have 2 meanings, but when using it for implicit type inference, it no longer has the RAII quality. So if you say "auto foo = 1" is much like "static bar = 1", you are mistaken. The 2nd one doesn't cause it to be non-static, so why does the 1st make it non-RAII? If auto for implicit type inference stays, I propose removing it for RAII in declarations. If you want RAII you can simply use scope(exit) delete baz; after the declaration. Also, the "auto class {}" form can still stay since it is in unrelated code and there is no easy replacement for it.
Mar 13 2006
"Chris Miller" <chris dprogramming.com> wrote in message news:op.s6csodzipo9bzi moe...There is a problem with auto when declaring variables! Not only does it have 2 meanings, but when using it for implicit type inference, it no longer has the RAII quality. So if you say "auto foo = 1" is much like "static bar = 1", you are mistaken. The 2nd one doesn't cause it to be non-static, so why does the 1st make it non-RAII? If auto for implicit type inference stays, I propose removing it for RAII in declarations. If you want RAII you can simply use scope(exit) delete baz; after the declaration. Also, the "auto class {}" form can still stay since it is in unrelated code and there is no easy replacement for it.Sigh.. was it really necessary to start another thread about this?
Mar 13 2006
In article <dv3u5j$2ot1$1 digitaldaemon.com>, Jarrett Billingsley says..."Chris Miller" <chris dprogramming.com> wrote in message news:op.s6csodzipo9bzi moe...Sorry, why to do that? I don't want to be forced to free every object manually with scope(exit)? Then it wouldn't be RAII anymore! Or I don't understand your point.There is a problem with auto when declaring variables! Not only does it have 2 meanings, but when using it for implicit type inference, it no longer has the RAII quality. So if you say "auto foo = 1" is much like "static bar = 1", you are mistaken. The 2nd one doesn't cause it to be non-static, so why does the 1st make it non-RAII? If auto for implicit type inference stays, I propose removing it for RAII in declarations. If you want RAII you can simply use scope(exit) delete baz; after the declaration.Tom;Also, the "auto class {}" form can still stay since it is in unrelated code and there is no easy replacement for it.Sigh.. was it really necessary to start another thread about this?
Mar 13 2006
On Mon, 13 Mar 2006 10:02:49 -0500, Tom <Tom_member pathlink.com> wrote:In article <dv3u5j$2ot1$1 digitaldaemon.com>, Jarrett Billingsley says...They accomplish the same thing, but perhaps scope can be used to indicate RAII: scope(raii) Foo f = new Foo; or scope(auto) etc"Chris Miller" <chris dprogramming.com> wrote in message news:op.s6csodzipo9bzi moe...Sorry, why to do that? I don't want to be forced to free every object manually with scope(exit)? Then it wouldn't be RAII anymore! Or I don't understand your point.There is a problem with auto when declaring variables! Not only does it have 2 meanings, but when using it for implicit type inference, it no longer has the RAII quality. So if you say "auto foo = 1" is much like "static bar = 1", you are mistaken. The 2nd one doesn't cause it to be non-static, so why does the 1st make it non-RAII? If auto for implicit type inference stays, I propose removing it for RAII in declarations. If you want RAII you can simply use scope(exit) delete baz; after the declaration.
Mar 14 2006
In article <op.s6fkcmh7po9bzi moe>, Chris Miller says...On Mon, 13 Mar 2006 10:02:49 -0500, Tom <Tom_member pathlink.com> wrote:Oh I see. But to be obliged to add 'scope(exit) delete foo' after every RAII declaration isn't nice at all (though it is actually possible as an alternative to 'auto'). I think I'd prefer replace RAII-'auto' for the keyword 'local' since that keyword is straightforward to what it means. And now it comes to me the question: why is so important to have implicit type inference? Tom;In article <dv3u5j$2ot1$1 digitaldaemon.com>, Jarrett Billingsley says...They accomplish the same thing, but perhaps scope can be used to indicate RAII: scope(raii) Foo f = new Foo; or scope(auto) etc"Chris Miller" <chris dprogramming.com> wrote in message news:op.s6csodzipo9bzi moe...Sorry, why to do that? I don't want to be forced to free every object manually with scope(exit)? Then it wouldn't be RAII anymore! Or I don't understand your point.There is a problem with auto when declaring variables! Not only does it have 2 meanings, but when using it for implicit type inference, it no longer has the RAII quality. So if you say "auto foo = 1" is much like "static bar = 1", you are mistaken. The 2nd one doesn't cause it to be non-static, so why does the 1st make it non-RAII? If auto for implicit type inference stays, I propose removing it for RAII in declarations. If you want RAII you can simply use scope(exit) delete baz; after the declaration.
Mar 14 2006
Tom wrote:In article <op.s6fkcmh7po9bzi moe>, Chris Miller says...<snip><snip> Scope statements themselves create a scope, judging by analogy with other statements and the lack of any information to the contrary. It would seem a little strange to make scope(raii) an exception.... Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:- C++ a->--- UB P+ L E W++ N+++ o K- w++ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.They accomplish the same thing, but perhaps scope can be used to indicate RAII: scope(raii) Foo f = new Foo; or scope(auto) etc
Mar 15 2006
Chris Miller wrote:There is a problem with auto when declaring variables! Not only does it have 2 meanings, but when using it for implicit type inference, it no longer has the RAII quality. So if you say "auto foo = 1" is much like "static bar = 1", you are mistaken. The 2nd one doesn't cause it to be non-static, so why does the 1st make it non-RAII? If auto for implicit type inference stays, I propose removing it for RAII in declarations.The RAII meaning of auto came first. D programmers from pre-0.137 days are going to be confused when they discover that auto has nothing in common with its old self.If you want RAII you can simply use scope(exit) delete baz; after the declaration. Also, the "auto class {}" form can still stay since it is in unrelated code and there is no easy replacement for it.OK, so it will still have this in common. But the way the auto keyword is overloaded will look no less a mess. If we're going to change the auto keyword, we should change at least one of its meanings to be denoted by a whole new keyword. Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:- C++ a->--- UB P+ L E W++ N+++ o K- w++ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Mar 15 2006