Philippe Sigaud <[email protected]> wrote:
On Mon, Sep 27, 2010 at 19:20, Simen kjaeraas
<[email protected]>wrote:
Here's mine ( 8/11 at compile-time, the remaining at runtime ):
http://ideone.com/6WlFJ
I don't think it's possible to make it better than that in D without,
as you say, for instance type states.
Yeah, I concur. OK for doing the first 8 tests at CT. But at CT you have
only enums, so you cannot reassign 'variables'.I cannot find a way to
change
a cow state from alive to dead.
Encoding the cow's state in its type is no good either, as you cannot
change
a cow's type. I think OCaml does it with algebraic data types. These are
doable in D, but only testable at runtime...
If pointers were available at compile-time, it'd doable. Didn't Don say
we
should get classes and pointers at CT at some time?
I guess it actually is doable at CT, by coding the whole puzzle within
the confines of CTFE or TMP. I'm not going to, though.
--
Simen