The Thermopylae excerpt of TDPL available online
bearophile
bearophileHUGS at lycos.com
Fri Oct 30 03:44:08 PDT 2009
Don:
> traits.compiles(XXX)
> traits.typeid(TTT)
> traits.stringof(T)
> traits.allMembers(T)
> traits.error("message");
Cute.
Simpler alternative, the dot isn't necessary:
traits_compiles(XXX)
traits_typeid(TTT)
traits_stringof(T)
traits_allmembers(T)
traits_error("message");
Or, more uniformly (all D needs more identifier style uniformity):
traits_compiles(XXX)
traits_type_id(TTT)
traits_string_of(T)
traits_all_members(T)
traits_error("message");
> For bonus points, allow 'with(traits)':
> with(traits) {
> if (compiles(XXX)) return stringof(T);
> else error("Can't use " ~ stringof(T) ~ " in a transmogrifier.");
> }
Not nice. Bad.
Bye,
bearophile
More information about the Digitalmars-d
mailing list