Browse thread
[Caml-list] match on dynamic type
-
Olivier Ricordeau
-
Olivier Ricordeau
- Olivier Ricordeau
-
Olivier Ricordeau
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Olivier Ricordeau <olivier.ricordeau@w...> |
| Subject: | Re: [Caml-list] match on dynamic type |
-----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