On Saturday, 7 April 2012 at 11:25:15 UTC, Manu wrote:
Generating a struct for an attribute is fine. It's not like you
go on
a custom attribute frenzy attributing everything with different
stuff. You
may have a few useful attributes, and those given by libs that
you just use.
Why can't you use alias template parameters in a struct
definition in just
the same way?
Structs are definitely preferable in my opinion, for the fact
that they can
have methods and properties and stuff. If you get an attribute
of
something, being about to use methods on it, or access
calculated data via
properties will be useful.
I see no reason to name an attribute differently than the thing
that
happens to define it.
The calling methods is a valid point, however the method can
return a struct as well.
Ultimately, I don't think it makes a large difference at all
which is used. I'm just leaning towards methods because there's
less bloat, no issues with this() like with a struct, and can be
slightly simpler in certain situations.
Again, it's mostly minor things. I'd be quite happy with either
approach.