Function attribute best practices
john.michael.hall at gmail.com
Tue Sep 13 12:17:48 UTC 2022
On Monday, 12 September 2022 at 16:39:14 UTC, Paul Backus wrote:
> Yes. Except for `@trusted`, explicit attributes on template
> code are a smell.
If I can be 100% sure that something will always be
@safe/nothrow/pure/@nogc, then I might consider marking them as
such. For instance, a function that takes any floating point
type, does some calculation, and then returns it. I figure it is
documented for the user and at least this will save the compiler
the effort of figuring it. If I can't, then I don't.
More information about the Digitalmars-d-learn