auto -> auto & var

David Gileadi David_member at pathlink.com
Fri Mar 10 13:26:32 PST 2006


I'm a lurker in this NG; I don't usually join in but as a newbie to D this seems
to be one of the few inelegant things about it.  It's not a deal-breaker, just
confusing and a bit annoying.

The proposal below has been suggested before.  I think it's a good one, and add
my vote to it.

-Dave

In article <duspas$2dfo$1 at digitaldaemon.com>, Kramer says...
>
>I keep tripping myself over the double meaning of auto.  I know it shouldn't be
>that difficult to remember that auto means type inference and also stack
>allocation/RAII, but does it have to be that way?
>
>I don't know if anyone else agrees, but I wouldn't mind seeing auto's uses
>properly split:
>
>var -> type inference
>auto -> RAII
>
>I remember it also being mentioned that the syntax could possibly change to
>allow classes to be created on the stack like so:
>
>Class c = new Class() // heap
>Class c = Class() // stack
>
>But if auto can be split so it's meaning isn't overloaded, I think then auto
>would do just fine for this scenario.
>
>The specs state "An implicit type inference for a class reference is not an auto
>declaration, even if the auto storage class is used".  That's just one more
>thing to remember and confuse a newbie.
>
>Sorry if this sounds like a rant (it was more of a hasty frustration) and
>everyone is ok with auto as-is; I can certainly live just fine with it.  It just
>seems more natural *not* overloaded.
>
>-Kramer
>
>





More information about the Digitalmars-d mailing list