caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Puzzling typing of recursive classes.
@ 2012-03-02 22:21 Jean-Louis Giavitto
  0 siblings, 0 replies; only message in thread
From: Jean-Louis Giavitto @ 2012-03-02 22:21 UTC (permalink / raw)
  To: caml-list

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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-03-02 22:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-02 22:21 [Caml-list] Puzzling typing of recursive classes Jean-Louis Giavitto

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).