caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] examples of heterogenous collections (containers ?)
@ 2004-03-31  4:55 briand
  2004-03-31  5:41 ` Matt Gushee
  0 siblings, 1 reply; 8+ messages in thread
From: briand @ 2004-03-31  4:55 UTC (permalink / raw)
  To: caml-list


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-04-01 12:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-31  4:55 [Caml-list] examples of heterogenous collections (containers ?) briand
2004-03-31  5:41 ` Matt Gushee
2004-03-31  6:45   ` briand
2004-03-31  9:04     ` skaller
2004-04-01  4:00       ` briand
2004-04-01  5:38         ` Issac Trotts
2004-04-01  7:20         ` skaller
2004-03-31  7:28   ` Martin Jambon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).