caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Recursive classes are impossible?
@ 2002-06-24 13:59 Alessandro Baretta
  2002-06-24 21:34 ` Gerd Stolpmann
  0 siblings, 1 reply; 5+ messages in thread
From: Alessandro Baretta @ 2002-06-24 13:59 UTC (permalink / raw)
  To: Ocaml

 > Due to the typing system it is more or less impossible to
 > derive recursive classes in O'Caml. To get around this, it
 > is common practice to put the modifiable or extensible
 > part of recursive objects into parallel objects.
<http://www.ocaml-programming.de/packages/documentation/pxp/manual/x550.html#AEN582>

Hmmm... Now I am no object specialist, but this sounds a 
little weird to me. Now, let's see, doesn't the following 
code show that recursive classes are indeed possible in 
O'Caml? Or have I completely misunderstood what is meant by 
recursive object?

class ['a] broccoli =
	object (s)
	val mutable portion = None;
	method set (x:'a option) = portion <- x
end;;

let broccolo = new broccoli in
	broccolo#set (Some new broccoli);;

let broccolo = new broccoli in
	broccolo#set (Some broccolo);;

Sorry for mentioning broccoli, but it seemed appropriate 
given the recursive nature of their geometry.

Alex

-------------------
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] 5+ messages in thread

end of thread, other threads:[~2002-06-26  2:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-24 13:59 [Caml-list] Recursive classes are impossible? Alessandro Baretta
2002-06-24 21:34 ` Gerd Stolpmann
2002-06-24 23:55   ` james woodyatt
2002-06-25 23:48   ` Alessandro Baretta
2002-06-26  2:43     ` John Prevost

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).