From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA05824; Tue, 22 Jul 2003 19:45:32 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA02792 for ; Tue, 22 Jul 2003 19:45:31 +0200 (MET DST) Received: from kraid.nerim.net (smtp-102-tuesday.nerim.net [62.4.16.102]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h6MHjUT24324 for ; Tue, 22 Jul 2003 19:45:31 +0200 (MET DST) Received: from wanadoo.fr (ricordeau.net1.nerim.net [213.41.149.166]) by kraid.nerim.net (Postfix) with ESMTP id 7563240E40 for ; Tue, 22 Jul 2003 19:45:29 +0200 (CEST) Message-ID: <3F1D783A.1040100@wanadoo.fr> Date: Tue, 22 Jul 2003 19:45:30 +0200 From: Olivier Ricordeau User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr-FR; rv:1.4) Gecko/20030630 X-Accept-Language: fr-fr, en-us, en MIME-Version: 1.0 To: caml-list@inria.fr Subject: Re: [Caml-list] match on dynamic type References: <3F1D5DA6.7090602@wanadoo.fr> <3F1D65CF.5090406@wanadoo.fr> In-Reply-To: <3F1D65CF.5090406@wanadoo.fr> X-Enigmail-Version: 0.76.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 hash:01 foo:01 non-mutable:01 basile:01 lynx:01 1.2.2:01 gyn:99 ocaml:01 inherit:01 olivier:02 match:02 pgp:02 addict:02 gpg:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk -----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