Attributes on Enum Members: Call for use cases.
Meta
jared771 at gmail.com
Wed Nov 29 17:17:55 UTC 2017
On Wednesday, 29 November 2017 at 16:45:04 UTC, Timon Gehr wrote:
> On 29.11.2017 17:21, Andrei Alexandrescu wrote:
>> On 11/29/2017 07:53 AM, Seb wrote:
>>> UDAs for function arguments would be really awesome to have.
>>
>> They should be part of the same DIP. -- Andrei
>
> More generally, any declaration should ideally support UDAs.
>
> One issue with UDAs on function arguments is that function
> types will then have embedded UDAs, so the DIP should specify
> how that works.
You have much more experience in how compilers work on the
implementation level than me. What semantics are possible?
It makes sense to me that UDAs on function arguments should only
be for documentation/reflection purposes. Therefore:
int fun(@Nonnull Object o);
Is considered to be equivalent to:
int fun(Object o);
And similarly:
import std.traits;
Parameters!fun -> (Object), not (@Nonnull Object)
However:
int fun(@Nonnull Object o)
{
static if (is(typeof(fun) Params == __parameters))
{
static foreach (p; Params)
{
pragma(msg, __traits(getUDAs, p)); //Should print
Nonnull
}
}
}
Unfortunately I don't think we can have both as that would mean
that UDAs would have to be part of the function signature. Is
there a way around this?
More information about the Digitalmars-d
mailing list