Who wore it better?

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 15 21:08:31 PDT 2016


On Friday, April 15, 2016 13:46:24 Andrei Alexandrescu via Digitalmars-d 
wrote:
> On 04/15/2016 01:31 PM, Namespace wrote:
> > Since it is a template: Why these attributes: @trusted pure nothrow ?
>
> @trusted is not inferrable, the others are type-independent and nice for
> the documentation. -- Andrei

Yes. I definitely think that it should be standard policy in Phobos (if not
D code in general) to only use attribute inference when it's actually
required. Without attribute inference, attributes and templates really
wouldn't work together (which is why we have it), but the cost is that you
don't know what the actual attributes are without compiling the code. So,
while some folks may not like the extra typing, I think that it's clearly
better for everyone who has to look at or maintain a function and/or its
documentation to know what its attributes are by looking just at it, even if
it's a little bit of extra work for the person who writes the function
initially.

I honestly wish that we hadn't added attribute inference to auto return
functions, since I think that it's just enabling a bad practice.

- Jonathan M Davis



More information about the Digitalmars-d mailing list