DIP64: Attribute Cleanup

Artur Skawina via Digitalmars-d digitalmars-d at puremagic.com
Sat Jun 21 12:33:44 PDT 2014


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


More information about the Digitalmars-d mailing list