Comment #0 by timothee.cour2 — 2018-03-15T09:45:38Z
templated functions should in general have their attributes inferred
lots of functions violate this, eg:
auto uninitializedArray(T, I...)(I sizes) nothrow @system
std/complex.d:37:24:auto complex(R)(R re) @safe pure nothrow @nogc
pure bool isLoggingEnabled()(LogLevel ll) @safe nothrow @nogc
std/math.d:646:23:auto conj(Num)(Num z) @safe pure nothrow @nogc
context: see https://github.com/dlang/phobos/pull/6178#discussion_r174693271
Comment #1 by issues.dlang — 2018-03-17T00:45:18Z
Templated functions should have their attributes inferred when whether attributes make sense depend on the template arguments (which the often do). However, if the attributes don't depend on the template arguments, then they really should be explicit. Whether any of the ones listed should have attributes inferred which currently are explicit, I don't know (I'd have to study them to know), and it's quite possible that all of the attributes listed here should be removed, but I don't think that it's a good policy to just not put attributes on templated functions. Whether they should be there or not depends on whether they depend on the template arguments.
Comment #2 by chilli — 2018-03-17T04:55:27Z
(In reply to Jonathan M Davis from comment #1)
> Templated functions should have their attributes inferred when whether
> attributes make sense depend on the template arguments (which the often do).
> However, if the attributes don't depend on the template arguments, then they
> really should be explicit. Whether any of the ones listed should have
> attributes inferred which currently are explicit, I don't know (I'd have to
> study them to know), and it's quite possible that all of the attributes
> listed here should be removed, but I don't think that it's a good policy to
> just not put attributes on templated functions. Whether they should be there
> or not depends on whether they depend on the template arguments.
Your guideline is new for me (but makes sense to me).
Please, add this to https://dlang.org/dstyle.html, which "misguided" me.
Comment #3 by robert.schadek — 2024-12-01T16:33:03Z