Can someone tell me what the compiler thought I was trying to do?

rikki cattermole rikki at cattermole.co.nz
Wed Oct 19 01:36:35 UTC 2022


On 19/10/2022 2:30 PM, H. S. Teoh wrote:
> On Wed, Oct 19, 2022 at 01:15:37AM +0000, Adam D Ruppe via Digitalmars-d-learn wrote:
>> On Wednesday, 19 October 2022 at 00:57:31 UTC, H. S. Teoh wrote:
>>> Has it really been implemented?  I tested the latest git master, the
>>> following code doesn't compile:
>>
>> it only applies to types, not to functions.
> 
> Wat... so what's the use of it then?  So it's not possible to mark the
> return value of an int function @mustUse without making, in theory,
> *all* ints @mustUse?
> 
> I must confess I'm baffled as to the purpose of this strange design.

Oh but it gets better:

 From C23 draft:

The nodiscard attribute shall be applied to the identifier in a function 
declaration or to the definition
of a structure, union, or enumeration type. If an attribute argument 
clause is present, it shall have
the form:
( string-literal )


More information about the Digitalmars-d-learn mailing list