custom attribute proposal (yeah, another one)

Steven Schveighoffer schveiguy at yahoo.com
Mon Apr 9 06:20:48 PDT 2012


On Sat, 07 Apr 2012 10:11:16 -0400, Jacob Carlborg <doob at me.com> wrote:

> On 2012-04-06 20:52, Steven Schveighoffer wrote:
>
>> Also, if I see:
>>
>> @square(5) int foo();
>>
>> How do I know that I have to use __traits(getAttribute, foo, Area)?
>
> Isn't "square" the name of the attribute? In that case you would use:
>
> __traits(getAttribute, foo, square)

The argument was to use the name of the type returned as the attribute  
name instead of the function.  That is not my proposal.  The suggested  
case is to be able to use a different name to build the same attribute, to  
be more intuitive.

i.e. both area and square create the Area attribute, but square only takes  
one parameter because it's a square.  Kind of like saying "the area is  
square".

So my counter point above is in the context that the type name of the  
return value becomes the attribute name.

-Steve


More information about the Digitalmars-d mailing list