Browse thread
[Caml-list] Recursive classes are impossible?
- Alessandro Baretta
[
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: | 2002-06-24 (13:53) |
From: | Alessandro Baretta <alex@b...> |
Subject: | [Caml-list] Recursive classes are impossible? |
> 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