From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 52418BB84 for ; Mon, 10 Jul 2006 21:21:36 +0200 (CEST) Received: from mail7.sea5.speakeasy.net (mail7.sea5.speakeasy.net [69.17.117.9]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k6AJLXru016792 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Mon, 10 Jul 2006 21:21:35 +0200 Received: (qmail 7409 invoked from network); 10 Jul 2006 19:21:26 -0000 Received: from shell2.sea5.speakeasy.net ([69.17.116.3]) (envelope-sender ) by mail7.sea5.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 10 Jul 2006 19:21:26 -0000 Date: Mon, 10 Jul 2006 12:21:26 -0700 (PDT) From: brogoff To: caml-list@yquem.inria.fr Subject: Polymorphic method question Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at nez-perce with ID 44B2A8BD.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; slap:01 ocaml:01 recursion:01 recursion:01 denali:01 ocaml:01 foobar:01 foobar:01 escapes:01 polymorphic:01 workaround:01 extensible:01 speakeasy:01 cleanly:01 btw:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=SPF_SOFTFAIL autolearn=disabled version=3.0.3 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