On 2012-03-21 17:00, Adam D. Ruppe wrote:
On Wednesday, 21 March 2012 at 15:02:15 UTC, Jacob Carlborg wrote:
Here's my proposal:

Ah yes, I think I did read that before.

I'm not in love with the key=value or the explicit
@attribute on the classes, which is the two biggest
differences we have.

The key=value is nice, but it isn't in the language today,
so it'd be a bunch of special code in the @attribute parser
in the compiler.

If we were to have key=value syntax, I say we should do it
generically (like C style struct initializers?) so it can
work in regular code too, then pick it up naturally here.

Would "key: value" be possible. The syntax we have for AA literals?

I'd prefer to use the existing language syntax in there
so the implementation can literally be as simple as:

if(token == TOKnote) {
token.next();
annotations ~= parseExpression();
}


D's existing struct syntax can handle arguments easily
enough with the StructName("member", "member"); style.
Reusing that here keeps the implementation simple,
and it might be more flexible:

enum MyNote = Something("with args", 2);

That would be nice.

@note(MyNote) int foo;
@note(MyNote) bool bar;

But I don't like the @note syntax. I really would like this:

@MyNote int foo;


The other thing is @attribute struct {} rather than just
struct {}. I don't any benefit to that. If I want to
reuse a regular, runtime struct to store info at compile
time, why shouldn't I be able to do that?

I just throw that in because Java has it. Don't know if it's needed or not. Java has a kind of special syntax for default values with annotations.

--
/Jacob Carlborg

Reply via email to