So, User-Defined Attributes
Jacob Carlborg
doob at me.com
Sat Jan 5 11:19:47 PST 2013
On 2013-01-05 19:54, Philippe Sigaud wrote:
> Good to know. I tested it with basic values and this fails:
>
> @"hello" int i;
> @3 inj j;
>
> Worth a bug report?
No, that's by design. When I added that syntax first but I was asked to
change it to only accept call expressions. Have a look at the grammar:
https://dl.dropbox.com/u/18386187/attribute.html#uda
> As a complement, multiple @'s are possible:
>
> @("hello") @(3) int j;
Yes, that's legal and is supposed to be. Have a look at Walters original
announcement:
http://forum.dlang.org/thread/k7afq6$2832$1@digitalmars.com
enum EEE = 7;
["hello"] struct SSS { }
[3] { [4][EEE][SSS] int foo; }
With the correct syntax that becomes:
enum EEE = 7;
@("hello") struct SSS { }
@(3) { @(4) @(EEE) @(SSS) int foo; }
Or:
@(3) { @(4) @EEE @SSS int foo; }
> And another complement:
>
> struct S {}
>
> @S S s; is possible.
> But
>
> @int S s;
>
> is not
That is not supposed to be legal (see above), but this might be:
@(int) S s;
Does that work?
> 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.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list