DIP64: Attribute Cleanup

Shammah Chancellor via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 22 05:18:04 PDT 2014


On 2014-06-21 19:33:44 +0000, Artur Skawina via Digitalmars-d said:

> On 06/21/14 19:56, Shammah Chancellor via Digitalmars-d wrote:
>> I like it, but I think the attribute sets should be based on then alias 
>> syntax though.
>> 
>> alias @attributeSet = (@attribute1, @attribute2, @attribute3);
> 
> Well, D does not have that kind of tuple syntax and introducing one for
> this special case wouldn't be a good idea. Other than that, this feature
> already exists, only it's currently limited to user defined attributes.
> The present syntax looks like this:
> 
>    alias Tuple(A...) = A;
>    alias attributeSet = Tuple!(attribute1, attribute2, attribute3);
> 
> and is already usable with UDAs and "magic" attributes:
> 
>    version (GNU) {
>    static import gcc.attribute;
>    enum noinline = gcc.attribute.attribute("noinline");
>    }
> 
>    struct other_attribute {}
> 
>    alias Tuple(A...) = A;
> 
>    alias spiffy = Tuple!(other_attribute, noinline);
> 
>    @spiffy int f(int a) { return a+a; }
> 
> I'm not sure inventing another syntax is necessary.
> 
> (Making the built-in (keyword) attributes less special is of course
> the hard part, but the choice of syntax shouldn't really affect that)
> 
> artur

So, basically we don't need special syntax for attribute sets, we just 
need to make it so built-in attributes are not "special?"

-Shammah



More information about the Digitalmars-d mailing list