On 2012-11-08 00:43, Adam D. Ruppe wrote:

One of the previous threads put forth something like this:

template MyAttribute(alias subject, T... arguments) { /* some
implementation */

The attribute is a template that replaces the declaration. So you type:

[MyAttribute("foo")]
class Something {}


And the compiler rewrites that to:

class __anonymous_Something {}

alias Something = MyAttribute!(__anonymous_Something, "foo");



... or something like that. I'm going off memory here. But then you can
use the template to do whatever you'd normally do with a template.

For some reason this feels incomplete to me. I know one of those
proposals enabled something we can't really do now, whereas what I
described here of course *can* be done now.

Seems like a poor man's replacement for macro annotations:

http://scalamacros.org/future.html

--
/Jacob Carlborg

Reply via email to