Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: boos@gr6.u-strasbg.fr (Christian Boos)
To: pbrisset@eis.enac.dgac.fr
Cc: caml-list@pauillac.inria.fr
Subject: Re: type and class definition : recursion
Date: Tue, 14 May 96 22:04:56 +0200	[thread overview]
Message-ID: <9605142004.AA03001@gr6.u-strasbg.fr> (raw)
In-Reply-To: <199605141211.OAA06278@concorde.inria.fr>


pbrisset@eis.enac.dgac.fr writes:
 > I would like to define a class and a type with a mutual recursion between
 > them. Something like
 > 
 > 	type t = A
 > 	       | B of c
 > 	and class c (x:t) =
 >           val mutable value = x
 > 	end
 > 
 > Is it possible with O'caml ?
 > 
 > --------------

Yes :

#type 'a t = A | B of 'a;;
type 'a t = A | B of 'a
#class c (x : 'a t) : 'a = val mutable value = x end;;
class c ('a t) : 'a =
  val mutable value : 'a t
end
#let foo = new c A;;
val foo : c = <obj>
#let bar = new c (B foo);;
val bar : c = <obj>
#

-- Christian





      reply	other threads:[~1996-05-15  8:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-05-14 12:11 pbrisset
1996-05-14 20:04 ` Christian Boos [this message]

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=9605142004.AA03001@gr6.u-strasbg.fr \
    --to=boos@gr6.u-strasbg.fr \
    --cc=caml-list@pauillac.inria.fr \
    --cc=pbrisset@eis.enac.dgac.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