caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jean-Louis Giavitto <jean-louis.giavitto@ircam.fr>
To: caml-list@inria.fr
Subject: [Caml-list] Puzzling typing of recursive classes.
Date: Fri, 02 Mar 2012 23:21:18 +0100	[thread overview]
Message-ID: <4F5147DE.7020102@ircam.fr> (raw)

Hello ocamlers,
the following behavior puzzle me. The typing of this fragment:

    class virtual ['a, 'b] a = object end

    class virtual ['b] b =
    object
      inherit ['b, 'b] a
    end

gives

    class virtual ['a, 'b] a : object  end
    class virtual ['a] b : object  end

but the the following code:

    class virtual ['a, 'b] a = object end

    and virtual ['b] b =
    object
      inherit ['b, 'b] a
    end

returns

    class virtual ['a, +'b] a : object constraint 'b = 'a end
    and virtual ['a] b : object  end

I don't understand why a constraint is added. The difference between the 
two fragments is that the declaration of class b is in the same "scope" 
as class a.


Anyway, my initial problem is to define two recursive classes (because 
methods in one refers to object of the other class and vice versa). But 
I should avoid the collapse of the two type parameters (more precisely, 
I have 4 type parameters and 3 classes that make some permutation 
between them). Any idea ?


Thank you,
Jean-Louis Giavitto.

                 reply	other threads:[~2012-03-02 22:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4F5147DE.7020102@ircam.fr \
    --to=jean-louis.giavitto@ircam.fr \
    --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).