From: brogoff <brogoff@speakeasy.net>
To: caml-list@yquem.inria.fr
Subject: Polymorphic method question
Date: Mon, 10 Jul 2006 12:21:26 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.58.0607101215080.5875@shell2.speakeasy.net> (raw)
Hi,
I'm sure I'll slap my forehead in disgust when someone lifts the
scales from my eyes, but I'm once again perplexed by a type error
from OCaml when using objects. Can someone tell me why I get the
error from the second case (with the classes connected by "and") when
the first case is OK?
BTW, This example was distilled from one in which I could not cleanly
remove the class recursion, one involving an "extensible visitor" in
which there is a recursion between the visited and visitor classes.
Assuming there's an obvious answer to my first question, is there a
nice workaround in this case?
brogoff@denali[tricks]$ ocaml
Objective Caml version 3.09.2
# class virtual ['a] bar =
object
method virtual get : 'a
end;;
class virtual ['a] bar : object method virtual get : 'a end
# class virtual foobar =
object
method virtual f : 'a . 'a bar -> 'a
end;;
class virtual foobar : object method virtual f : 'a bar -> 'a end
# class virtual ['a] bar =
object
method virtual get : 'a
end
and foobar =
object
method virtual f : 'a . 'a bar -> 'a
end;;
Characters 115-132:
method virtual f : 'a . 'a bar -> 'a
^^^^^^^^^^^^^^^^^
This type scheme cannot quantify 'a :
it escapes this scope.
--
-- Brian
next reply other threads:[~2006-07-10 19:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-10 19:21 brogoff [this message]
2006-07-10 20:05 ` [Caml-list] " Richard Jones
2006-07-10 23:25 ` brogoff
2006-07-11 2:24 ` skaller
2006-07-11 4:56 ` brogoff
2006-07-11 2:09 ` Jacques Garrigue
2006-07-11 5:22 ` brogoff
2006-07-11 7:32 ` Jacques Garrigue
2006-07-11 18:20 ` brogoff
2006-07-12 0:37 ` Jacques Garrigue
2006-07-12 19:26 ` brogoff
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=Pine.LNX.4.58.0607101215080.5875@shell2.speakeasy.net \
--to=brogoff@speakeasy.net \
--cc=caml-list@yquem.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