auto -> auto & var

Kramer Kramer_member at pathlink.com
Fri Mar 10 12:59:08 PST 2006


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