On Wednesday, April 17, 2013 12:35:07 Walter Bright wrote: > On 4/17/2013 8:07 AM, Andrei Alexandrescu wrote: > > On 4/16/13 4:20 PM, Peter Alexander wrote: > >> This is the point I have a problem with: > >>>> 2.2. One cannot opt out of nothrow or pure with auto functions. > >>> > >>> This argument has one solid answer: don't use auto when the need is to > >>> specify an attribute pattern explicitly. > >> > >> I find this unacceptable. Thanks to the proliferation of template code > >> in D, it is often rather difficult to spell out return types. > > > > Attribute inference is always done for templates. > > And, I might add, I cannot recall a single adverse issue that has caused.
If anything, the fact that it doesn't infer more is the problem. The primary risk is if a particular set of template arguments previously resulted in the function being pure, nothrow, or @safe but no longer do so after some code changes, and code using the template which requires pure, nothrow, or @safe then no longer compiles. But odds are that that's the fault changes to the template arguments and not the template, and requiring explict attributes wouldn't fix the problem anyway, because then you're either stuck with a combinatorial explosion of template declarations or making it so that the template always has the same set of attributes and therefore only works with code that works with that exact set of attributes. Non-templated auto functions are not generally in the same boat, because their types are usually well-known, and therefore explicitly marking the attributes that you want works, but it may still be reasonable to do attribute inferrence for them. - Jonathan M Davis