Explicit Declaration of Pureness and Throwness of Higher Order Ranges

"Nordlöw" per.nordlow at gmail.com
Mon Mar 10 15:42:46 PDT 2014


> I'm not quite sure what you're asking. You either mark a 
> function as @safe,
> pure, and/or nothrow - or you don't, in which case, if it's a 
> templated
> function, the attributes are inferred to the best of the 
> compiler's
> capabilities, and if it's not, then the function doesn't have 
> those
> attributes.
>
> If you're asking whether we should prefer to be explicit with 
> attributes on
> template functions, then the answer is no. We want the 
> inference to be done by
> the compiler for the very reason that it was introduced in the 
> first place.
> Without inference, if the function is marked with @safe, pure, 
> or nothrow,
> then that restricts the list of valid template arguments to 
> arguments that
> fulfill those requirements, and if we don't mark the templated 
> function as
> @safe, pure, or nothrow, then it can't be used in other 
> functions marked with
> those attributes.
>
> Now, prior to dmd 2.065, the attribute inference was pretty 
> poor, but it looks
> like the various bugs with regards to that were fixed:
>
> http://dlang.org/changelog.html#attribinference2
>
> So, attribute inference should be working much better now.
>
> - Jonathan M Davis

That's exactly the answer I asked for and wanted to hear ;)

Thanks again,
Sifu


More information about the Digitalmars-d-learn mailing list