caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain Frisch <frisch@clipper.ens.fr>
To: <wrader@OCF.Berkeley.EDU>
Cc: <caml-list@inria.fr>
Subject: Re: [Caml-list] A class that contains instances of itself?
Date: Sat, 5 Jan 2002 14:16:50 +0100 (MET)	[thread overview]
Message-ID: <Pine.GSO.4.33.0201051415220.29030-100000@clipper.ens.fr> (raw)
In-Reply-To: <200201051245.g05Cjxp24150@war.OCF.Berkeley.EDU>

On Sat, 5 Jan 2002 wrader@ocf.berkeley.edu wrote:

> I want to have an class that can contain instances
> of that same class.  Assume something like this:
> (ignore any easy syntax errors - I'm making
> up this example right now)
...

What about :

class someClass =
object(_ : 'self)
  val mutable anotherInstanceOfSomeClass : 'self option = None

  method talk () =
    print_string("Hello.\n")

  method setInstance x =
    anotherInstanceOfSomeClass <- Some x

  method useInstance () =
    match anotherInstanceOfSomeClass with
      | Some a -> a # talk ()
      | None -> ()
end


?

-- 
  Alain

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


  parent reply	other threads:[~2002-01-05 13:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-05 12:45 wrader
2002-01-05 13:15 ` John Prevost
2002-01-05 13:16 ` Alain Frisch [this message]
2002-01-05 23:27   ` [Caml-list] IMAP library for Caml? Will Benton

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=Pine.GSO.4.33.0201051415220.29030-100000@clipper.ens.fr \
    --to=frisch@clipper.ens.fr \
    --cc=caml-list@inria.fr \
    --cc=wrader@OCF.Berkeley.EDU \
    /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).