caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alessandro Baretta <alex@baretta.com>
To: Ocaml <caml-list@inria.fr>
Subject: [Caml-list] Recursive classes are impossible?
Date: Mon, 24 Jun 2002 15:59:53 +0200	[thread overview]
Message-ID: <3D1725D9.7060409@baretta.com> (raw)

 > 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


             reply	other threads:[~2002-06-24 13:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-24 13:59 Alessandro Baretta [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3D1725D9.7060409@baretta.com \
    --to=alex@baretta.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).