caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Pixel <pixel@mandrakesoft.com>
To: John Max Skaller <skaller@ozemail.com.au>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Is a Cow an Animal?
Date: 18 Apr 2002 12:19:28 +0200	[thread overview]
Message-ID: <lyelhdpavj.fsf@leia.mandrakesoft.com> (raw)
In-Reply-To: <3CBE2CC8.1030407@ozemail.com.au>

John Max Skaller <skaller@ozemail.com.au> writes:

[...]

> You ask in the title "Is a cow an animal?". The answer is no.

well, it depends how you define your animal. It *can* be as seen at

http://pauillac.inria.fr/~remy/work/virtual/virtual005.html
(written by famous guys :)

> Use a variant, give up on classes:

[...]

> You can do a bit better sometimes, by recognising
> some commonality:
> 
> type Animal = {
>   animal_common:animal_part;
>   animal_variant:animal_split
> }
> 
> type animal_split = Horse of horse | Cow of cow
> ...
> 
> so that the horse type only contains features unique
> to horses. But you should really forget abstraction,
> and just build concrete data structures: its really
> just a large in memory database, after all:
> you really won't gain much hiding the representation here.

well, i don't *want* to give up concrete data structures, I'm just trying to
write the thing. I don't care wether if it's abstract or not. Any working
solution accepted.

http://merd.net/pixel/language-study/various/is-a-cow-an-animal/ocaml.listing
uses a variant for the kind (I just changed it, it was a string)

I've still kept the class to allow sharing of fields.

BUT this solution doesn't allow a stricter checking alike ocaml2.listing or
c++2.listing. The reason is that you can't parameter the class with values
(like (Vegetable Carrot)) only types. 

Maybe this is possible with polymorphic variants (?), I'll try...
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2002-04-18 10:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-17 23:40 Pixel
2002-04-18  2:17 ` John Max Skaller
2002-04-18 10:19   ` Pixel [this message]
2002-04-18 12:09     ` Pixel
2002-04-18 12:52       ` Jacques Garrigue
2002-04-18 13:03         ` Pixel
2002-04-18 18:58 ` james woodyatt
2002-04-18 22:44   ` Pixel
2002-04-18 22:57     ` james woodyatt
2002-04-18 23:31       ` Pixel
2002-04-19  0:21   ` Remi VANICAT
2002-04-19  0:51     ` james woodyatt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=lyelhdpavj.fsf@leia.mandrakesoft.com \
    --to=pixel@mandrakesoft.com \
    --cc=caml-list@inria.fr \
    --cc=skaller@ozemail.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).