On Wed, Sep 29, 2010 at 23:10, bearophile <[email protected]> wrote: > Philippe Sigaud: > >> If doing state passing like this is authorized, it might be doable >> doing 11/11 with D, at the type level. > > From what I have seen this puzzle gives few rules, but then the > implementation is quite free. It's not a true competition, with strict rules. > I think the spirit of the game is to catch many violations at compile time, > while keeping the program "useful".
I was wondering how you can 'return' two types from a template and then use them independantly... For example Eat!(Who, What) could be a template that returns two types (let access them through .Who and .What) which are the new states. But then, you can do that with CTFE too: auto whoWhat = who.eat(what); // eat returns a Tuple!(Who, Eaten!What) who2 = whoWhat[0]; eatenWhat = whoWhat[1]; (Damn, how I miss tuple extraction in D) eatenWhat has type Eaten!What, which is different from What and is not a food anymore. So the compiler will catch: who2.eat(eatenWhat); at compile time. The same idea can be used for slaughtering something twice, and such. But to me, that's cheating (I'm not pretending miasma's code is cheating. I am not fluent enough in Scala) Philippe
