On 6 April 2012 17:23, Steven Schveighoffer <schveiguy@yahoo.com> wrote:
You can store a struct, just return it from an attribute function.

e.g.:

@attribute Author author(string name) { return Author(name);}

Why should we be restricted to only structs?  Or any type for that matter?

The benefit to using CTFE functions is that the compiler already knows how to deal with them at compile-time.  i.e. less work to make the compiler implement this.

Yep, I see now. If this is significantly simpler, then so be it. Whatever gets it done. This certainly meets my requirements.


I also firmly believe that determining what is allowed as attributes should be opt-in.  Just allowing any struct/class/function/etc. would lead to bizarre declarations.

I see your point, and I also had this thought. I'm on the fence though, not sure if it's valuable or not.
Does this approach really change that though? It could return anything it likes, and then it's no different than binding one of those directly.