From: Olivier Andrieu <andrieu@ijm.jussieu.fr>
To: onlyclimb <onlyclimb@163.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] How to throw away oop?
Date: Mon, 9 Dec 2002 15:10:15 +0100 [thread overview]
Message-ID: <15860.42055.229312.122122@akasha.ijm.jussieu.fr> (raw)
In-Reply-To: <3DF50918.7040704@163.com>
onlyclimb [Monday 9 December 2002] :
> DNA and Protein can be a subclass of Seq. And in fact there are many
> kind of sequences , so we can suppose the number of the kind of Seq is
> infinite. ie. the subclasses of Seq can be infinite. and DNA and
> Protein are just two of them
Do you really think you'll have to subclass your Seq often ? I mean,
you have DNA, proteins and this is it (you can add RNA if you want to
nitpick). In this case, ie when your datatypes are fixed and you're not
going to extend them, you can simply use a variant type.
module DNA =
type t = ...
let length = ...
end
module Protein =
type t = ...
let length = ...
end
and you can build a generic module for functions common in DNA and
Protein :
module Seq =
type t =
| DNA of DNA.t
| Protein of Protein.t
let length = function
| DNA s -> DNA.length s
| Protein s -> Protein.length s
end
--
Olivier
-------------------
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
next prev parent reply other threads:[~2002-12-09 14:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-09 21:20 onlyclimb
2002-12-09 13:45 ` Didier Le Botlan
2002-12-09 14:10 ` Olivier Andrieu [this message]
2002-12-09 18:43 ` brogoff
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=15860.42055.229312.122122@akasha.ijm.jussieu.fr \
--to=andrieu@ijm.jussieu.fr \
--cc=caml-list@inria.fr \
--cc=onlyclimb@163.com \
/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