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 GAA10715; Wed, 31 Mar 2004 06:55:40 +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 GAA12457 for ; Wed, 31 Mar 2004 06:55:38 +0200 (MET DST) From: briand@aracnet.com Received: from obsidian.spiritone.com (obsidian.spiritone.com [216.99.193.137]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i2V4uLjq011555 for ; Wed, 31 Mar 2004 06:56:22 +0200 Received: from soggy.deldotd.com (216-99-206-32.cust.aracnet.com [216.99.206.32]) by obsidian.spiritone.com (8.12.10/8.12.8) with ESMTP id i2V54j63011997 for ; Tue, 30 Mar 2004 21:04:45 -0800 Received: from briand by soggy.deldotd.com with local (Exim 3.36 #1 (Debian)) id 1B8XlI-0002wy-00 for ; Tue, 30 Mar 2004 20:55:36 -0800 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16490.20296.852406.613011@soggy.deldotd.com> Date: Tue, 30 Mar 2004 20:55:36 -0800 To: caml-list@inria.fr Subject: [Caml-list] examples of heterogenous collections (containers ?) X-Mailer: VM 6.92 under Emacs 21.2.1 X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; objs:01 inherit:01 inherit:01 objects:02 objects:02 obj:03 obj:03 iter:03 data:03 bits:05 derived:05 derived:05 structure:06 obvious:06 quite:06 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I'm embarking on that most typical of ewexamples, the heterogenous list. So I have objects: base_class virtual method derived_class_A inherit base_class derived_class_B inherit base_class ... And I would like to collect instances of derived_class_B, derived_class_B etc.. into a data structure. The obvious example is that I'd like to collect the objects into a list and do something like : List.iter (f obj -> obj#method) list_of_objs or is (obj :> base_class)#method ? I've done quite a bit of searching but I cannot seem to find a "clean" example of doing the above, just bits and pieces. Can anyone point me to any examples or code ? Thanks Brian ------------------- 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