From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 85CF67ED25 for ; Sat, 20 Jul 2013 15:12:51 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of goswin-v-b@web.de) identity=pra; client-ip=212.227.15.14; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="goswin-v-b@web.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of goswin-v-b@web.de) identity=mailfrom; client-ip=212.227.15.14; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="goswin-v-b@web.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mout.web.de) identity=helo; client-ip=212.227.15.14; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="postmaster@mout.web.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArkCAIuL6lHU4w8OnGdsb2JhbABavyqGQxYOAQEBAQEGDQkJFCiCUhN7NAUoFYgcARaWMpZvH4kWkCyCem4Dl1yGEY5R X-IPAS-Result: ArkCAIuL6lHU4w8OnGdsb2JhbABavyqGQxYOAQEBAQEGDQkJFCiCUhN7NAUoFYgcARaWMpZvH4kWkCyCem4Dl1yGEY5R X-IronPort-AV: E=Sophos;i="4.89,708,1367964000"; d="scan'208";a="26719613" Received: from mout.web.de ([212.227.15.14]) by mail2-smtp-roc.national.inria.fr with ESMTP; 20 Jul 2013 15:12:51 +0200 Received: from frosties.localnet ([95.208.119.3]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0LetQh-1ULSiz1JlP-00qglU for ; Sat, 20 Jul 2013 15:12:50 +0200 Received: from mrvn by frosties.localnet with local (Exim 4.80) (envelope-from ) id 1V0Wxt-0008Ob-Ml for caml-list@inria.fr; Sat, 20 Jul 2013 15:12:49 +0200 Date: Sat, 20 Jul 2013 15:12:49 +0200 From: Goswin von Brederlow To: caml-list@inria.fr Message-ID: <20130720131249.GA32103@frosties> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Provags-ID: V03:K0:C+vbH0mxbLRqZyvqPv3AdKc2Uk2t+5svtDszChRf+6j/eg5qI5g pDnKDcm/E8M340OAn9dHxyHeAbl5PyG/4Qi6DFd/HI5T0xTX1APZPxQkYU2+0YOKTkFt5cd k2UO8XFJUZY0OgAqrSFPUhwv5sLCpJ2Fw2KjcqY0/IhTmtSWng8f07l1NW78ej7f+SxcQXH 5UOc+otv7PczS5HA7VE7g== Subject: [Caml-list] implicit subtyping fails with recursive classes Hi, I'm trying to add implicit subtyping to a pair of recurisve classes: Without subtyping: ------------------ class type foo = object method foo : t -> unit end and t = object method push : foo -> unit end With that I can call t#push (x :> foo) for any x that implements the foo interface. What I want: ------------ # class type foo = object method foo : t -> unit end and t = object method push : 'a . (#foo as 'a) -> unit end;; ^^^^^^^^^^^^^^^^^^^^^^^^^ Error: The universal type variable 'a cannot be generalized: it escapes its scope. The problem seems to be the recursive definition with "and". Here is an example with and without "and": (* works *) class type foo = object method foo : string end;; class type bar = object inherit foo method bar : string end;; class type t = object method push : 'a . (#foo as 'a) -> unit end;; (* fails *) class type foo = object method foo : string end and bar = object inherit foo method bar : string end and t = object method push : 'a . (#foo as 'a) -> unit end;; So what am I doing wrong? MfG Goswin