FeedbackThread: DIP 1038-- at nodiscard--Community Review Round 1

Paul Backus snarwin at gmail.com
Fri Dec 11 20:44:00 UTC 2020


On Friday, 11 December 2020 at 20:01:38 UTC, Jacob Carlborg wrote:
> On 2020-12-09 11:11, Mike Parker wrote:
>> This is the feedback thread for the first round of Community 
>> Review of DIP 1038, "@nodiscard".
>
> The DIP doesn't mention anything about constructors. It should 
> mention if this attribute can be applied to constructors. It 
> should also mention if it applies to if the attribute is 
> attached to the type and a constructor is called for that type.

These cases are both covered by the rules given in the DIP.

1) A constructor is a function. Therefore, @nodiscard can be 
applied to a constructor.
2) For any type T, a call to T's constructor is an expression of 
type T. Therefore, if T is an aggregate type whose declaration is 
annotated with @nodiscard, that expression will be considered 
non-discardable.


More information about the Digitalmars-d mailing list