caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Polymorphic method question
@ 2006-07-10 19:21 brogoff
  2006-07-10 20:05 ` [Caml-list] " Richard Jones
  2006-07-11  2:09 ` Jacques Garrigue
  0 siblings, 2 replies; 11+ messages in thread
From: brogoff @ 2006-07-10 19:21 UTC (permalink / raw)
  To: caml-list

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



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2006-07-12 19:26 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-10 19:21 Polymorphic method question brogoff
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).