[contest] Is a Cow an animal ++

Philippe Sigaud philippe.sigaud at gmail.com
Mon Sep 27 14:52:11 PDT 2010


On Mon, Sep 27, 2010 at 19:20, Simen kjaeraas <simen.kjaras at gmail.com>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?


Philippe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20100927/1db28fff/attachment.html>


More information about the Digitalmars-d mailing list