Thread overview
[dmd-beta] const attribute etc
Jun 02, 2013
Walter Bright
Jun 02, 2013
Andrej Mitrovic
Jun 02, 2013
Jonathan M Davis
June 02, 2013
I see documentation at http://dlang.org/attribute.html for const, immutable, shared, inout attributes.

I think we must extricates those from there. They are qualifiers, and have distinct properties from attributes.


Thoughts?

Andrei
_______________________________________________
dmd-beta mailing list
dmd-beta@puremagic.com
http://lists.puremagic.com/mailman/listinfo/dmd-beta

June 02, 2013
I have awaited it all the time since got familiar with D. The fact that in spec everything is listed as an attriubute makes initial studying of the type system rather difficult. C++ is far from perfect, too, but at least they have some separation between qualifiers, storage classes, protection attributes etc. That helps.

On Sun, Jun 2, 2013 at 10:19 PM, Andrei Alexandrescu <andrei@erdani.com> wrote:
> I see documentation at http://dlang.org/attribute.html for const, immutable, shared, inout attributes.
>
> I think we must extricates those from there. They are qualifiers, and have distinct properties from attributes.
>
>
> Thoughts?
>
> Andrei
> _______________________________________________
> dmd-beta mailing list
> dmd-beta@puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-beta
_______________________________________________
dmd-beta mailing list
dmd-beta@puremagic.com
http://lists.puremagic.com/mailman/listinfo/dmd-beta

June 02, 2013
On 6/2/2013 12:19 PM, Andrei Alexandrescu wrote:
> I see documentation at http://dlang.org/attribute.html for const, immutable, shared, inout attributes.
>
> I think we must extricates those from there. They are qualifiers, and have distinct properties from attributes.

Remember that they are both a dessert topping and a floor wax.

(type constructor and storage class)
_______________________________________________
dmd-beta mailing list
dmd-beta@puremagic.com
http://lists.puremagic.com/mailman/listinfo/dmd-beta

June 02, 2013
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.

Andrei

On 6/2/13 6:18 PM, Walter Bright wrote:
>
> On 6/2/2013 12:19 PM, Andrei Alexandrescu wrote:
>> I see documentation at http://dlang.org/attribute.html for const,
>> immutable, shared, inout attributes.
>>
>> I think we must extricates those from there. They are qualifiers, and
>> have distinct properties from attributes.
>
> Remember that they are both a dessert topping and a floor wax.
>
> (type constructor and storage class)
> _______________________________________________
> dmd-beta mailing list
> dmd-beta@puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-beta
_______________________________________________
dmd-beta mailing list
dmd-beta@puremagic.com
http://lists.puremagic.com/mailman/listinfo/dmd-beta

June 03, 2013
On 6/3/13, Andrei Alexandrescu <andrei@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?
_______________________________________________
dmd-beta mailing list
dmd-beta@puremagic.com
http://lists.puremagic.com/mailman/listinfo/dmd-beta

June 02, 2013
On Monday, June 03, 2013 01:35:54 Andrej Mitrovic wrote:
> On 6/3/13, Andrei Alexandrescu <andrei@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
_______________________________________________
dmd-beta mailing list
dmd-beta@puremagic.com
http://lists.puremagic.com/mailman/listinfo/dmd-beta

June 02, 2013
Type constructor is a language construct that literally constructs a type (not a value), usually from one or more types. E.g. T[K] is a type constructor - given types T and K, constructs the type hash map etc.

So "new const(C)" is not a type constructor, it's at best an expression that constructs a value. "const(C)" is a type constructor that takes a type C and constructs a new type.

Type modifier is loosely-defined as a type constructor that takes one type and alters its properties just a bit.


Andrei

On 6/2/13 7:35 PM, Andrej Mitrovic wrote:
> On 6/3/13, Andrei Alexandrescu<andrei@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?
> _______________________________________________
> dmd-beta mailing list
> dmd-beta@puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-beta
_______________________________________________
dmd-beta mailing list
dmd-beta@puremagic.com
http://lists.puremagic.com/mailman/listinfo/dmd-beta