Thread overview | |||||
---|---|---|---|---|---|
|
February 06, 2016 Conflicting UDA | ||||
---|---|---|---|---|
| ||||
I came across an issue with UDAs and was wondering if there really is no way or if I just missed something... Basically, my library has an @ignore UDA, which conflicts with vibe.d's vibe.data.serialization. If both mine and vibe's module are imported, DMD will fail with a very non-descriptive error message, seen below... The obvious solution would be to prefix my UDAs, but then I suppose every library writer would have to abide by this convention, which in practice won't happen, and would bring us back to the C-style redundant symbol names all over. It's unpleasant to have to disambiguate even when not necessary... I suppose I could also do @mylibattr("ignore") instead, but this is also hideous and overly verbose... I tried @mylib.ignore, which would not be too bad, if necessary only to disambiguate, but it seems like the parser doesn't understand it. struct Score { uint id; ulong score; @ignore ulong score2 = 10; // Error: expression ignore is void and has no value } static assert(hasUDA!(Score.score2, IgnoreAttribute)); Something like would be intuitive: @mylib.ignore @vibe.ignore @std.somemodule.ignore ulong score2 = 10; What are other people doing to go around this? To me, this seems like a major UDA usability issue for library writers in the wild. |
February 06, 2016 Re: Conflicting UDA | ||||
---|---|---|---|---|
| ||||
Posted in reply to Márcio Martins | On Saturday, 6 February 2016 at 13:36:32 UTC, Márcio Martins wrote:
> I came across an issue with UDAs and was wondering if there really is no way or if I just missed something...
>
> Basically, my library has an @ignore UDA, which conflicts with vibe.d's vibe.data.serialization.
>
> If both mine and vibe's module are imported, DMD will fail with a very non-descriptive error message, seen below... The obvious solution would be to prefix my UDAs, but then I suppose every library writer would have to abide by this convention, which in practice won't happen, and would bring us back to the C-style redundant symbol names all over. It's unpleasant to have to disambiguate even when not necessary... I suppose I could also do @mylibattr("ignore") instead, but this is also hideous and overly verbose...
>
> I tried @mylib.ignore, which would not be too bad, if necessary only to disambiguate, but it seems like the parser doesn't understand it.
`@(mylib.ignore)` should work. You could open an enhancement request to enable the paren-less syntax.
|
February 06, 2016 Re: Conflicting UDA | ||||
---|---|---|---|---|
| ||||
Posted in reply to Marc Schütz | On Saturday, 6 February 2016 at 15:01:44 UTC, Marc Schütz wrote:
> On Saturday, 6 February 2016 at 13:36:32 UTC, Márcio Martins wrote:
>> [...]
>
> `@(mylib.ignore)` should work. You could open an enhancement request to enable the paren-less syntax.
Thanks, that does work indeed and is not that verbose...
Cheers!
|
Copyright © 1999-2021 by the D Language Foundation