[contest] Is a Cow an animal ++

Simen kjaeraas simen.kjaras at gmail.com
Mon Sep 27 15:12:55 PDT 2010


Philippe Sigaud <philippe.sigaud at gmail.com> wrote:

> 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?

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


More information about the Digitalmars-d mailing list