custom attribute proposal (yeah, another one)

Manu turkeyman at gmail.com
Fri Apr 6 07:45:06 PDT 2012


On 6 April 2012 17:23, Steven Schveighoffer <schveiguy at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120406/db2c9d03/attachment.html>


More information about the Digitalmars-d mailing list