On Fri, 17 Jan 2014 21:50:07 -0500, Stanislav Blinov <[email protected]> wrote:

On Saturday, 18 January 2014 at 02:38:28 UTC, H. S. Teoh wrote:

What's wrong with just letting the compiler infer the maximal function
attributes?

...

Sadly, this only works for template functions currently -- so I still
had to annotate the various method()'s by hand, but if you were to turn
them into template functions too, their attributes will also be inferred
automatically.

Oh, I see now where it went the wrong way. From my own example, of course :)

Surely I was meaning:

class Careful(T) {
//...
   void thisIsSoPolymorphic() nothrow(isNoThrow!(T.foo)) { ... }
//...
}

Something to that extent. So that yes, the function itself is not a template.

I was about to respond with a similar point, but it seems you are understanding now how the nothrow inference works :)

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). 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)

-Steve

Reply via email to