Feedback Thread: DIP 1038-- at nodiscard--Final Review

Walter Bright newshound2 at digitalmars.com
Thu Feb 4 09:09:02 UTC 2021


1. > Note that the former is a syntax-level check, while the latter is a 
type-level check. This means that the value returned from a @nodiscard function 
may in fact be discarded as long as the function call itself is enclosed in some 
other expression.

These two sentences do not make sense together. The second sentence only refers 
to the syntax-level check.


2. Consider:

     @nodiscard int foo();
     a ? b : foo();

discards the return result of foo(), but according to the DIP no error will be 
detected. This is another case of the comma expression one mentioned in the 
Description.

This is a critical shortcoming in the DIP that needs to be addressed. Perhaps 
this feature in other languages can provide guidance.


More information about the Digitalmars-d mailing list