Explicit keyword for "plain old local variable" storage class?
Norbert Nemec
Norbert at Nemec-online.de
Sun May 28 10:02:00 PDT 2006
Jarrett Billingsley wrote:
> "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.
Sorry, but I disagree:
before type inference came along, "auto" already had a meaning. It said:
"This is *not* a plain old local variable but one that is deleted
automatically at end of scope." (In your terms, "auto" always meant RAII
in D)
> 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();
What you suggest here, is to change the meaning of "auto" and then
introduce a new keyword for what was "auto" before. At the moment,
"auto" means RAII. What we need is a keyword for non-RAII storage class.
Up to now, such a keyword was not necessary. With type inference, it
became necessary.
More information about the Digitalmars-d
mailing list