Am Fri, 27 Dec 2013 13:45:10 +0000 schrieb "bearophile" <bearophileh...@lycos.com>:
> Timon Gehr: > > > mixin ADT!q{ Term: Var char | Op char Term[] }; > > > > void main(){ > > const expr = Op('f', [Op('g',[Var('x'), Var('y')]), > > Op('a',[]), Var('x')]); > > } > > Where is ADT defined? (And why isn't it a Phobos patch on GitHub?) > > > > convertNum could be written more compactly as: > > char convertNum(int x){ > > return "exyzfgh"[x<$?x:0]; > > That's too much compact :-) Humans put a space around operators, > and sometimes some parentheses don't hurt: > > char convertNum(in int x) pure nothrow > in { > assert(x >= 0); > } body { > return "exyzfgh"[(x < $) ? x : 0]; > } > > Bye, > bearophile Before you go _that_ far, just write: char convertNum(in size_t x) pure nothrow { return "exyzfgh"[(x < $) ? x : 0]; } :-) -- Marco