From: Damien <Damien.Pous@ens-lyon.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Mutually recursive classes
Date: Tue, 4 Nov 2003 18:52:12 +0100 [thread overview]
Message-ID: <20031104185212.7808ab96.Damien.Pous@ens-lyon.fr> (raw)
In-Reply-To: <20031103174144.0299613CBAB@garonne.edcsm.jussieu.fr>
I could solve my problem by first defining two "open class type", and
then unifying 'self with the parameter in two other class types :
<<
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
>>
It was the same kind of problem as the one discussed in
<http://caml.inria.fr/archives/200303/msg00349.html>
the parameters of a class are generalized after its type has been
inferred.
thus, with
<<
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
>>
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
next prev parent reply other threads:[~2003-11-04 17:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-03 17:41 pous damien
2003-11-04 17:52 ` Damien [this message]
-- strict thread matches above, loose matches on Subject: below --
2003-11-03 10:48 Damien
2003-11-03 13:53 ` Didier Remy
2003-11-07 7:34 ` skaller
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=20031104185212.7808ab96.Damien.Pous@ens-lyon.fr \
--to=damien.pous@ens-lyon.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