On Saturday, 18 January 2014 at 03:02:45 UTC, Steven
Schveighoffer wrote:
I was about to respond with a similar point, but it seems you
are understanding now how the nothrow inference works :)
O:)
I can't think of a correct way to do this without repeating
code, since it has to be polymorphic (and therefore not a
template), nothrow inference only works on templates.
The idea to be able to attach attributes/annotations based on
compile-time introspection would be a worthy addition to the
language IMO, but I really don't like the syntax you have
outlined (I see you don't like it either).
No, I actually quite like that C++ syntax, although AFAIK it's
only "special" in that one particular occasion. I was mentioning
that syntax doesn't matter because I wanted to make sure I'm not
pushing any C++ features here, just making a point about a nice
usability feature :)
Especially if you have to do all the attributes this way.
I think a "use the attributes of X" would be a general enough
tool.
Something like:
void thisIsSoPolymorphic() attrOf(T.foo)
And here is where I would disagree. Fine-grained control over
each attribute is more important. For example, the function may
be always nothrow (say I handle all the exceptions in the world
or assert(0) on what's left; D helpfully doesn't consider
assert(0) as throwing :) ), but it may be conditionally pure or
safe.