custom attribute proposal (yeah, another one)
Mafi
mafi at example.org
Fri Apr 6 11:23:45 PDT 2012
Am 06.04.2012 17:17, schrieb Adam D. Ruppe:
> On Friday, 6 April 2012 at 15:07:04 UTC, Manu wrote:
>> But maybe the function approach has an
>> effect on the simplicity of the expression for a simple attribute,
>> like a single bool?
>
> Meh, it is pretty similar:
>
> struct Serializable { bool yes; }
> bool Serializable(bool yes) { return yes; }
>
There's one difference I think.
struct approach:
struct Area { int x, y; }
Area sqare(int a) { return Area(x, y); }
//foo and bar are attributed the same
@Area(5, 5) int foo();
@square(5) int bar();
whereas with the function approach:
@area(5, 5) int foo();
@square(5) int bar();
foo and bar have different attributes.
The problem is you can't define forwarding functions because the symbol
is the attribute type. This seems to be a major problem to me.
Mafi
More information about the Digitalmars-d
mailing list