On 6 April 2012 13:28, Walter Bright <newshound2@digitalmars.com> wrote:
On 4/6/2012 3:23 AM, Manu wrote:
What about:

struct editor
{
  this(string name, EditType, Colour = Colour.Default, string description = null)
  {
    //...
  }

  blah blah blah
}

@attr(editor("thing",...blah...))

Are you really changing the arguments for every declaration? Or is it one set that is repeated everywhere?

Of course, what's the point otherwise? This is the very definition of annotation.
Everything needs to be exposed in the editor differently.

The power of attributes are that they are tightly syntactically bound to the items they attribute. Nobody can change any class/struct without having the syntax force them to make any necessary corrections to their attributes too.


I don't see the advantage over:
@editor(...)

?

Name collisions with other @ attributes.

If they were declared as normal structs, they would follow normal namespace rules.

@company.lib.MyAttribute(...) should also be a valid expression.

The only collisions are @trusted, @safe... I think programmers can handle a few reserved keywords.
I already can't go and name a variable whatever I want for the same reason: int private = 10;