From: Goswin von Brederlow <goswin-v-b@web.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] implicit subtyping fails with recursive classes
Date: Tue, 23 Jul 2013 13:54:33 +0200 [thread overview]
Message-ID: <20130723115432.GA23436@frosties> (raw)
In-Reply-To: <87bo5xcapo.fsf@study.localdomain>
On Sat, Jul 20, 2013 at 08:06:43PM +0100, Leo White wrote:
>
> I am not sure, but I think the problem is that you are using #foo before
> it is fully defined, so it is becoming unified with the universal 'a and
> then when #foo is generalised the universal is escaping its scope.
>
> One way to avoid the problem is to expand out the type of #foo:
>
> # class type t = object method push : 'b. (< foo : t -> unit; ..> as 'b) -> unit end;;
> class type t = object method push : < foo : t -> unit; .. > -> unit end
> # class type foo = object method foo : t -> unit end;;
> class type foo = object method foo : t -> unit end
>
> if foo has a lot of methods, and you want to avoid typing them out
Yeah, the real code has rather a few more methods (9 occurances of t
in foo) so expanding out expands a lot. And since I'm still developing
the classes still change and then the change has to be copied to each
expanded type again. That is realy painfull.
> multiple times, you could try:
>
> # class type ['a] foo' = object method foo : 'a -> unit end;;
> class type ['a] foo' = object method foo : 'a -> unit end
> # class type t = object method push : 'b. (t #foo' as 'b) -> unit end;;
> class type t = object method push : t #foo' -> unit end
> # class type foo = [t] foo';;
> class type foo = [t] foo'
>
> Regards,
>
> Leo
I came up with that idea independently, too. But I parameterized t
instead of foo. This causes and Assert_failure in the toplevel:
http://caml.inria.fr/mantis/view.php?id=6083
But the way you suggest with ['a] foo', t and foo works. Luckily so far I
only need subtyping in t.
The other idea to circumvent his I had was using recursive modules but
I haven't tried that.
MfG
Goswin
prev parent reply other threads:[~2013-07-23 11:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-20 13:12 Goswin von Brederlow
2013-07-20 19:06 ` Leo White
2013-07-23 11:54 ` Goswin von Brederlow [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=20130723115432.GA23436@frosties \
--to=goswin-v-b@web.de \
--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