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 8B09E81799 for ; Tue, 23 Jul 2013 13:54:34 +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: AvsBAKdu7lHU4w8Om2dsb2JhbABBGoM7u1eFMoERFg4BAQEBAQYLCwkUKIIkAQEEAScTRAsLGAklDwUoiDEBDAoIM68AH4kWkBoWgnpuA5dcgSqEZ45R X-IPAS-Result: AvsBAKdu7lHU4w8Om2dsb2JhbABBGoM7u1eFMoERFg4BAQEBAQYLCwkUKIIkAQEEAScTRAsLGAklDwUoiDEBDAoIM68AH4kWkBoWgnpuA5dcgSqEZ45R X-IronPort-AV: E=Sophos;i="4.89,727,1367964000"; d="scan'208";a="27009828" Received: from mout.web.de ([212.227.15.14]) by mail2-smtp-roc.national.inria.fr with ESMTP; 23 Jul 2013 13:54:34 +0200 Received: from frosties.localnet ([95.208.119.3]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0MQvgI-1UXERT2OTO-00UGhe for ; Tue, 23 Jul 2013 13:54:33 +0200 Received: from mrvn by frosties.localnet with local (Exim 4.80) (envelope-from ) id 1V1bAn-00069A-2B for caml-list@inria.fr; Tue, 23 Jul 2013 13:54:33 +0200 Date: Tue, 23 Jul 2013 13:54:33 +0200 From: Goswin von Brederlow To: caml-list@inria.fr Message-ID: <20130723115432.GA23436@frosties> References: <20130720131249.GA32103@frosties> <87bo5xcapo.fsf@study.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87bo5xcapo.fsf@study.localdomain> User-Agent: Mutt/1.5.21 (2010-09-15) X-Provags-ID: V03:K0:2iBe9WIbH8phllxwHtX2wBKv8D0p2VDo75Z10vrBSwh/hWRBU05 M2eonK8Z97p4/enwn7h1GP1vTjvHL4pfYJI4t2GrCxRAU1Cs9EbHYqPowBoa7eAQ76WqmLo vuCrL9WG8oZqAwifK39CnfyhjLbj4S0H22Ay8cTW7ib/PGarWeUn7X/sAS/cscI2hruBhiU otK14lLQg5VF+Rx4kOVMg== Subject: Re: [Caml-list] implicit subtyping fails with recursive classes 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