Explicit keyword for "plain old local variable" storage class?

Jarrett Billingsley kb3ctd2 at yahoo.com
Sat May 27 11:54:18 PDT 2006


"Norbert Nemec" <Norbert at Nemec-online.de> wrote in message 
news:e596k7$2k4o$1 at digitaldaemon.com...

> Maybe that common confusion could be lifted by introducing a new storage
> class (e.g. "local" or "var") indicating a "plain old local variable".
> This would be the default for any variable declared with a type and
> without storage class, but it would be useful in declaring a
> type-induced variable that is not intended to be an auto variable.

We already have it; it's called "auto"  ;)  That's exactly what auto means - 
a plain old variable, one which is not accessible once the scope ends.  It's 
already the default storage class for variables declared without one. 
That's why we use auto to indicate type inference for most variables, 
because they're plain old local variables, and that's the default storage 
class.

The problem is just when it comes to auto classes.  Either we come up with a 
new keyword for the behavior of auto classes, i.e. "raii":

raii Foo f = new Foo();

// Type inference
raii g = new Goo();

Or, something I was thinking - just reuse scope, as it's not used by itself 
anywhere.

scope Foo f = new Foo();

Though I'll admit, it's not as self-explanatory as "raii Foo". 





More information about the Digitalmars-d mailing list