From: Guillaume Yziquel <guillaume.yziquel@citycable.ch>
To: Jean-Louis Giavitto <jean-louis.giavitto@ircam.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Contraintes dans la définitionrécursive de classes
Date: Fri, 18 Feb 2011 22:34:39 +0100 [thread overview]
Message-ID: <20110218213439.GA4106@localhost> (raw)
In-Reply-To: <4D5ECD89.6060906@ircam.fr>
Le Friday 18 Feb 2011 à 20:50:33 (+0100), Jean-Louis Giavitto a écrit :
> Bonjour.
>
> Je rencontre le problème suivant : une définition récursive de
> classe contraint les types paramètres de la classe, plus que je ne
> le souhaiterais.
>
> Je ne comprend pas d'où viennent ces contraintes supplémentaires.
> Voici un exemple minimal :
>
> class virtual ['a, 'b] base =
> object
> method virtual m : 'a -> 'b derive
> end
>
> and virtual ['a] derive =
> object
> inherit ['a, 'a] base
> end
A solution might be to break the recursive definition and the class and
push it to a module level. You should probably be able to use recursive
modules to make "forward declarations".
yziquel@seldon:~$ ocaml
Objective Caml version 3.12.0
# module rec M : sig
class virtual ['a, 'b] base : object
method virtual m : 'a -> 'b M.derive
end
class virtual ['a] derive : object
inherit ['a, 'a] base
end
end = M;;
module rec M :
sig
class virtual ['a, 'b] base :
object method virtual m : 'a -> 'b M.derive end
class virtual ['a] derive :
object method virtual m : 'a -> 'a M.derive end
end
#
--
Guillaume Yziquel
prev parent reply other threads:[~2011-02-18 21:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-18 19:50 Jean-Louis Giavitto
2011-02-18 21:34 ` Guillaume Yziquel [this message]
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=20110218213439.GA4106@localhost \
--to=guillaume.yziquel@citycable.ch \
--cc=caml-list@inria.fr \
--cc=jean-louis.giavitto@ircam.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