View mode: basic / threaded / horizontal-split · Log in · Help
April 15, 2012
Re: Definitive list of storage classes
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-in-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.

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

Jens
April 16, 2012
Re: Definitive list of storage classes
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
April 16, 2012
Re: Definitive list of storage classes
Jonathan M Davis wrote:
> 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.

I tend to leave out the parameter storage classes ref, in, out, and
lazy. I think D has the storage classes static and extern (just learned
why extern can be considered a storage class). And it dropped C's auto
(default storage) and C's register storage class.

> 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.

Yes, you're right. Walter and/or Andrei should give a precise
definition. I believe that TDPL is wrong when it says ref and static are
storage classes. Why should one combine parameter passing and storage
classes of data? I follow C's definition.

> > 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

Thanks for this clarification.

Jens
April 17, 2012
Re: Definitive list of storage classes
So, since they haven't said anything, does this mean that neither
Walter nor Andrei have the answer to this question? or is this
something a lot more complicated ?
April 17, 2012
Re: Definitive list of storage classes
On Monday, April 16, 2012 19:57:04 Caligo wrote:
> So, since they haven't said anything, does this mean that neither
> Walter nor Andrei have the answer to this question? or is this
> something a lot more complicated ?

My guess is that they haven't read the thread, but I don't know.

- Jonathan M Davis
April 17, 2012
Re: Definitive list of storage classes
On Mon, Apr 16, 2012 at 9:20 PM, Jonathan M Davis <jmdavisProg@gmx.com> wrote:
> On Monday, April 16, 2012 19:57:04 Caligo wrote:
>> So, since they haven't said anything, does this mean that neither
>> Walter nor Andrei have the answer to this question? or is this
>> something a lot more complicated ?
>
> My guess is that they haven't read the thread, but I don't know.
>
> - Jonathan M Davis

I'll call Walter tomorrow morning and ask him.
April 17, 2012
Re: Definitive list of storage classes
On 4/16/12 9:20 PM, Jonathan M Davis wrote:
> On Monday, April 16, 2012 19:57:04 Caligo wrote:
>> So, since they haven't said anything, does this mean that neither
>> Walter nor Andrei have the answer to this question? or is this
>> something a lot more complicated ?
>
> My guess is that they haven't read the thread, but I don't know.

I just did now and I don't quite get what the rumpus is. I don't have a 
rigorous definition of "storage class" as I have e.g. for type 
qualifier. The thing that matters is what a storage class is _not_, i.e. 
it doesn't change the type of the variable.

Andrei
April 17, 2012
Re: Definitive list of storage classes
On Monday, April 16, 2012 22:58:44 Andrei Alexandrescu wrote:
> On 4/16/12 9:20 PM, Jonathan M Davis wrote:
> > On Monday, April 16, 2012 19:57:04 Caligo wrote:
> >> So, since they haven't said anything, does this mean that neither
> >> Walter nor Andrei have the answer to this question? or is this
> >> something a lot more complicated ?
> > 
> > My guess is that they haven't read the thread, but I don't know.
> 
> I just did now and I don't quite get what the rumpus is. I don't have a
> rigorous definition of "storage class" as I have e.g. for type
> qualifier. The thing that matters is what a storage class is _not_, i.e.
> it doesn't change the type of the variable.

Well, the term gets bandied around a fair bit without an actual definition, and 
the fact that a big deal is made about something being a type qualifier rather 
than a storage class raises the question as to what on earth a storage class 
is. I raised the question primarily because of this question on stackoverflow:

http://stackoverflow.com/questions/10150510/what-are-the-storage-classes-in-d

- Jonathan M Davis
Top | Discussion index | About this forum | D home