<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/11/1ee94b3bad28167b8c0c0b07144c8827"
  from="Damien &lt;Damien.Pous@e...&gt;"
  author="Damien"
  date="2003-11-04T17:50:36"
  subject="Re: [Caml-list] Mutually recursive classes"
  prev="2003/11/2c0eec700da6320a17bcd3d2469d1a05"
  next="2003/11/dec982bc53112706fdf5984d7d508524"
  prev-in-thread="2003/11/1d87c05e41bbe7ce253007f8039e67d7"
  prev-thread="2003/11/ef8d11d2a3f4c6fd8183db8286734f46"
  next-thread="2003/11/5bfc54158708ba55850a695ef7c3c554"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="Re: [Caml-list] Mutually recursive classes">
<msg 
  url="2003/11/1d87c05e41bbe7ce253007f8039e67d7"
  from="pous@e..."
  author="pous@e..."
  date="2003-11-03T17:41:47"
  subject="Re: [Caml-list] Mutually recursive classes">
<msg 
  url="2003/11/1ee94b3bad28167b8c0c0b07144c8827"
  from="Damien &lt;Damien.Pous@e...&gt;"
  author="Damien"
  date="2003-11-04T17:50:36"
  subject="Re: [Caml-list] Mutually recursive classes">
</msg>
</msg>
</thread>

<contents>
I could solve my problem by first defining two "open class type", and
then unifying 'self with the parameter in two other class types :

&lt;&lt;
class type ['a, 'b] a_ot = object
	constraint 'b = ('a, 'b) #b_ot
	method	 coerce: 'a
	method	b: 'b
end and ['a, 'b] b_ot = object
	constraint 'a = ('a, 'b) #a_ot
	method	 coerce: 'b
	method	a: 'a
end

class type ['b] a_t = object ('s) inherit ['s, 'b] a_ot end
class type ['a] b_t = object ('s) inherit ['a, 's] b_ot end
&gt;&gt;

It was the same kind of problem as the one discussed in
&lt;http://caml.inria.fr/archives/200303/msg00349.html&gt;

the parameters of a class are generalized after its type has been
inferred.
thus, with

&lt;&lt;
class type ['b] a = object ('sa)
  method coerce: 'sa
  method b: 'b
  constraint 'b = 'sa #b
end and ['a] b = object ('sb)
  method coerce: 'sb
  method a: 'a
  constraint 'a = 'sb #a
end
&gt;&gt;

ocaml tries to unify 'sa (resp. 'sb) and 'a (resp. 'b) which is
impossible since this would close the self types

I lack some OO theory knowledges to understand the Jacques Garrigue's
distinction between "structural definition" and "definition by name"
(could someone explain me or send me some useful links ?)

but I think that recursion with distinct type parameters should be
allowed in the case above (recursive class _types_),
disallowing it seems to me like a boring syntactic restriction, since
one can always :
 - duplicate and separate the class type definitions ; (a_ot, b_ot)
 - add parameters for forward type definitions ('a, 'b)
 - glue all these types together to find back the first ones (a_t, b_t)

Does anyone know a case where this is not true ? (with class types)
What kind of "fully-recursive" classes are meaningless (just curious)

thanks,
damien

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

