Discussion Thread: DIP 1038-- at nodiscard--Final Review
IGotD-
nise at nise.com
Fri Feb 5 01:04:01 UTC 2021
On Thursday, 4 February 2021 at 20:15:07 UTC, Q. Schroll wrote:
>
> I wonder how many non-void functions exist whose return values
> are usually ignored.
There are plenty of them and I do it all the time. Sometimes it
is unnecessary and sometimes not and I pay the price. I consider
@nodiscard a very niche problem in D, as described in the DIP
mostly for system code. I think that in system code you do so
much unsafe things anyway and if you want to be sure to check
return values, then check the documentation of the library that
you are using. It's a nanny when you need it the least.
I think the DIP is heavily influenced by Rust but there the
return value is part of the default language error handling which
makes more sense. In D there are exceptions but this DIP doesn't
regard them so the benefit is limited.
I think that having a compiler flag that warns when a return
value is not used should be enough. That should cover those
projects where always checking the return value is a requirement.
More information about the Digitalmars-d
mailing list