[dmd-beta] const attribute etc

Jonathan M Davis jmdavisProg at gmx.com
Sun Jun 2 16:39:45 PDT 2013


On Monday, June 03, 2013 01:35:54 Andrej Mitrovic wrote:
> On 6/3/13, Andrei Alexandrescu <andrei at erdani.com> wrote:
> > I think I have an understanding how that dual nature works for C++, but
> > not in D. Could you please give more detail. Then we can merge that with
> > the documentation, so you wouldn't have wasted time.
> 
> Oh yes, and then you can close this:
> http://d.puremagic.com/issues/show_bug.cgi?id=9970
> 
> But from my limited understanding:
> 
> new const(C) -> type constructor
> cast(const(C))(new C) -> type modifier
> void foo(const(C)) -> type modifier
> 
> Correct? No?

Well, the first one is the only one constructing with const, so I could see an 
argument that that's the only case where const is used as a type constructor, 
but it's arguably used as a type qualifier in all 3 cases. However, I think 
that the only one that even _might_ be argued as a storage class is the 3rd 
one's as the other two actually relate to changing the type. I would think 
that it would be simpler though just to always call const a type qualifying 
and not a storage class, since it's qualifying the type even when it's 
arguably being used as a storage class. We can just say that type qualifiers 
are part of the type and storage classes aren't and get a nice clean 
distinction between the two. Unless I'm missing something?

- Jonathan M Davis


More information about the dmd-beta mailing list