So, User-Defined Attributes

Philippe Sigaud philippe.sigaud at gmail.com
Sat Jan 5 11:56:41 PST 2013


>
> No, that's by design. When I added that syntax first but I was asked to
> change it to only accept call expressions.
>


>> @int S s;
>>
>> is not
>>
>
> That is not supposed to be legal (see above), but this might be:
>
> @(int) S s;
>
> Does that work?


No. It produces reams of error.



>  So user-defined types are OK, but not basic types. Looks like a
>> parsing/grammar problem for me, since attribute tuple sure should be
>> able to store built-in types.
>> Another bug report?
>>
>
> I'm not sure.


I find it strange that @MyType ... is OK, but not @3, when, at the same
time @(MyType) and @(3) are *both* OK.


Also, why is @("hello") and @(SomeType) authorized, but not @(int)?

One extreme or the other looks OK for me: either only user-defined types
are authorized (no @int, no @3) or everything a tuple can hold is
authorized (hence, @int). The latter is more in line with the D way.

Also, if parenthesis can be dropped, allow them to be dropped for anything
that's a token long, as is done for template arguments. That seems coherent
with the rest of the language.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130105/778714ad/attachment.html>


More information about the Digitalmars-d mailing list