Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Markus Mottl <mottl@miss.wu-wien.ac.at>, OCAML <caml-list@inria.fr>
Subject: Re: Using modules and classes recursively
Date: Tue, 12 Jan 1999 18:29:19 +0100	[thread overview]
Message-ID: <19990112182919.00681@pauillac.inria.fr> (raw)
In-Reply-To: <199901092024.VAA15046@miss.wu-wien.ac.at>; from Markus Mottl on Sat, Jan 09, 1999 at 09:24:39PM +0100

> Is it impossible to have modules and classes combined recursively?

Currently, yes.  A module definition cannot be mutually recursive with
any other definition (type, class, or another module).  This raises a
number of difficult typechecking and compilation problems that are
still largely open.  I agree this is probably the most irritating
restriction of ML modules.

> If yes, what would be a good workaround?

I'm afraid you just have to define your own "set" type, without using
the Set.Make functor.  E.g.

        type 'a myset = Empty | Node of myset * 'a * myset

        (* an efficient implementation of myset can easily be
           lifted from the sources of the "Set" standard library
           module *)

        class foo =
          object
            method bar = (... : foo myset)
            ...
          end

This isn't very satisfactory, but I'm afraid we can't do better until
recursive modules are better understood.

Regards,

- Xavier Leroy




  reply	other threads:[~1999-01-12 17:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-01-09 20:24 Markus Mottl
1999-01-12 17:29 ` Xavier Leroy [this message]
1999-01-12 18:49   ` Brian Rogoff
1999-01-12 19:20     ` Markus Mottl

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=19990112182919.00681@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=mottl@miss.wu-wien.ac.at \
    /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