Am 06.04.2012 20:52, schrieb Steven Schveighoffer:
On Fri, 06 Apr 2012 14:23:45 -0400, Mafi <m...@example.org> wrote:
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.
[...]
Also, if I see:
@square(5) int foo();
How do I know that I have to use __traits(getAttribute, foo, Area)?
Another possibility:
@attribute Area area(int w, int h) { return Area(w, h);}
@attribute Area area(Area a) { return a;}
Area square(int a) { return Area(a, a);}
@area(5, 5) int foo();
@area(square(5)) int bar();
-Steve
The second possibility looks good. Especially because the lack of
@attribute on square disallows @square.
Mafi