User Defined Attributes

Walter Bright newshound2 at digitalmars.com
Tue Nov 6 09:00:22 PST 2012


On 11/6/2012 8:47 AM, bearophile wrote:
> Walter Bright:
>
>> It would be a significant extension, and so I'd like to see a compelling use
>> case first.
>
> Right. Combined with the trait to read function arguments, it's useful to add
> semantics to function arguments. This is good.

Ok, I ask again, what use case for a UDA is there for function parameters? (Note 
that IDL isn't it, as D already has enough parameter attributes to support IDL.)


>> User defined attributes cannot invent new semantics for the language.
>
> Right, that's my point :-)

So it cannot work for the use case you suggested. I'm still asking for a 
compelling use case.


>> And besides, 'ref' already does what you suggest.
>
> Nope. I have discussed the topic here:
> http://forum.dlang.org/thread/znbtczbgipqqzllafmzk@forum.dlang.org
>
> "ref" is useful to denote Case2 of that post of mine. But the @copy annotation I
> was talking here is the very uncommon (but unfortunately often used by mistake,
> and common source of bugs) Case3.

I don't see how having the user add a UDA is better than having the user add 
"const".


More information about the Digitalmars-d-announce mailing list