Conflicting UDA
Márcio Martins via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Feb 6 05:36:32 PST 2016
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.
More information about the Digitalmars-d-learn
mailing list