So, User-Defined Attributes

Philippe Sigaud philippe.sigaud at gmail.com
Sat Jan 5 14:44:59 PST 2013


On Sat, Jan 5, 2013 at 11:14 PM, Walter Bright
<newshound2 at digitalmars.com>wrote:

> On 1/5/2013 2:06 PM, Philippe Sigaud wrote:
>
>> But why is @(MyType) accepted, whereas @(int) is not?
>>
>
> Because it's looking for an expression inside the parents, and int is not
> an expression.
>
>
Well, first that would be nice to have the grammar online :)

Even if I understand the grammar restriction, from a user PoV this is quite
unexpected: a built-in type is a completely legal part of a D tuple. Either
it should be restricted to user-defined types (something I don't like), or,
if attributes are supposed to be tuples, then any tuple element should be
authorized.

And I will not buy a possible argument saying that I can wrap an int inside
a user-defined type. Yes, I can. But then, there is the same solution for
@(3) or @("Hello") and *these* are legal.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130105/71aec6c8/attachment-0001.html>


More information about the Digitalmars-d mailing list