From: Olivier Ricordeau <olivier.ricordeau@wanadoo.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] match on dynamic type
Date: Tue, 22 Jul 2003 19:45:30 +0200 [thread overview]
Message-ID: <3F1D783A.1040100@wanadoo.fr> (raw)
In-Reply-To: <3F1D65CF.5090406@wanadoo.fr>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Olivier Ricordeau wrote:
>>Hi!
>>I'd like to know how I can make a match on an object's dynamic type. Let
>>a be an abstract class. Let b and c be two class which inherit from a.
>>I'd like to write a method which looks like this:
>>
>>method foo (bar : a) =
>> match "a's dynamic type" with
>
> I meant:
> match "bar's dynamic type" with
>
>
>> b -> do_something()
>> | c -> do_something_else()
According to two mails I've just received from members of this list:
- -> This cannot be done with OCaml
- -> The trick is to add an string attribute (non-mutable) which contains
the dynamic type to the mother class.
Thanks to Basile Starynkevitch and Richard Jones for their help.
- --
- -= *Olivier RICORDEAU* =- http://freefolks.org
< LibNN addict http://libnn.org >
lynx -source http://freefolks.org/key.asc | gpg --import
olivier.ricordeau@wanadoo.fr _Might the source be with you_
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iD8DBQE/HXgZDFRYKP6DJEwRAnFNAJ0UkMPQ2k7OgTIF6D9GYn3FGpAh2wCfW8wl
OI6wM1qf2StTgaJO+uFhnMQ=
=jLY1
-----END PGP SIGNATURE-----
-------------------
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
prev parent reply other threads:[~2003-07-22 17:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-07-22 15:52 Olivier Ricordeau
2003-07-22 16:26 ` Olivier Ricordeau
2003-07-22 17:45 ` Olivier Ricordeau [this message]
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=3F1D783A.1040100@wanadoo.fr \
--to=olivier.ricordeau@wanadoo.fr \
--cc=caml-list@inria.fr \
/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