Definitive list of storage classes

Jonathan M Davis jmdavisProg at gmx.com
Sun Apr 15 22:40:30 PDT 2012


On Sunday, April 15, 2012 18:44:27 Jens Mueller wrote:
> Jonathan M Davis wrote:
> > I'd like to know which modifiers are considered to be storage classes. The
> > term seems to be used on a lot more than actually qualifies (including
> > using the term for the type qualfiers: const, immutable, and shared), and
> > even the documentation uses it on stuff that I wouldn't have thought
> > would be considered storage classes, because they have no effect on how
> > variables are stored or linked (e.g. synchronized).
> > 
> > Someone asked about it on stackoverflow, and my explanation is not as good
> > as it should be simply because I can't find a definitive list anywhere:
> > 
> > http://stackoverflow.com/questions/10150510/what-are-the-storage-classes-i
> > n-d
> I would say that static is the only storage class. By default data is
> thread local and not shared.
> 
> enum is not a storage class because nothing is stored here (I mean in
> memory at run time).
> 
> extern is not a storage class. Because it just says that the symbol
> needs to be resolved at link-time.
> 
> lazy says something about time of evaluation not how a variable's memory
> is stored.
> 
> out is about parameter passing. Same for ref. So I think ref is not a
> storage class. If it was I would expect ref a = 10 to be valid code.

TDPL specifically lists ref, in, out, and static as being storage classes. I'd 
fully expect lazy to be for the same reason, and extern is in C, so it 
probably is in D as well.

Regardless, I'm not concerned about what any particular person thinks is or 
isn't a storage class. I want to know what is _officially_ a storage class. 
Clearly, Walter and Andrei seem to have a definition in mind, since they talk 
about const, immutable, and shared being type qualifiers rather than storage 
classes, but as far as I can tell, they've never elaborated on what _is_ a 
storage class beyond a few specific ones mentioned in TDPL.

> Don't know about scope. I never used it. Is it going to be deprecated,
> isn't is?

scope on local variables is going away. scope on function parameters isn't.

http://dlang.org/function.html

- Jonathan M Davis


More information about the Digitalmars-d mailing list