UDA magic?

Dicebot public at dicebot.lv
Thu Apr 17 06:22:00 PDT 2014


Right now it is impossible by the design of feature. UDA's are 
just bits of information attached to symbols. They don't affect 
type of symbol and their own type is affected by symbol either. 
Such enhancement is theoretically possible but that would have 
been a very big change.

Current idiomatic way to do such stuff is to have single mixin 
statement that iterates over all symbols of a module and does 
something for those that have specific UDA attached:

@token!42
void foo() {}

mixin registerAllTokens!modname;


More information about the Digitalmars-d-learn mailing list