Definitive list of storage classes
Jonathan M Davis
jmdavisProg at gmx.com
Sat Apr 14 10:50:03 PDT 2012
On Sunday, April 15, 2012 01:49:09 Daniel Murphy wrote:
> "Jonathan M Davis" <jmdavisProg at gmx.com> wrote in message
> news:mailman.1707.1334377994.4860.digitalmars-d at puremagic.com...
>
> > 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
> >
> > - Jonathan M Davis
>
> There's always the list in 'declaration.h'.
That's clearly not the list, since it includes const, immutable, and shared,
which are type qualifiers rather than storage classes. It also has stuff like
init in it, which isn't even vaguely a storage class. All of the storage
classes may be in that list, but I don't know how you'd figure out which ones
they are from that list.
> If I had to guess I'd say 'storage class' meant something much more specific
> in C than it does in D, where it seems to mean properties of a declaration
> that do not affect the type.
Except that both Walter and Andrei seem to talk about type
qualifiers/constructors and storage classes as if they meant essentially the
same thing as in C/C++. For instance, talking about const as being a type
qualifier rather than a storage class doesn't mean anything to a non-D audience
unless it means essentially the same thing as in C. Also, the documentation
lists synchronized as being a storage class whereas it affects no variables
whatsoever and all of the descriptions of storage classes in TDPL act like
storage classes are for variables only. But synchronized doesn't affect
scoping, storage, or linking at all as a storage class in C would, so that
would at least seem to indicate that something other than the C definition is
being used.
Regardless, if a storage class does not have a specific definition separate from
D which can be applied to D, then D needs to give its own definition for what
on earth the term means, and I don't find _anywhere_ that does that. Everywhere
that mentions it seems to assume that you have some idea of what it means
already. TDPL _does_ sort of try and define it, but not really. It pretty much
just lists certain modifiers as being storage classes without giving a full
list or explaining exactly what constitutes a storage class. The closest thing
that it gives to a definition
"Each function parameter (base and exponent in the example above) has, in
addition to its type, an optional storage class that decides the way that
arguments are passed to the function when invoked."
would seem indicate that static (which it later says is a storage class) isn't
a storage class at all, since storage classes would only apply to function
parameters (which would also disqualify synchronized as a storage class, which
would be at odds with the online docs).
So, I'd like an official definition of storage class with a list of what qualifies
as a one in D. But it wouldn't surprise me at all if Walter's the only one who
can do that.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list