From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA22938 for caml-redistribution; Wed, 11 Dec 1996 16:34:04 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA19507 for ; Wed, 11 Dec 1996 14:16:37 +0100 (MET) Received: from margaux.inria.fr (margaux.inria.fr [128.93.8.2]) by concorde.inria.fr (8.7.6/8.7.1) with ESMTP id OAA27665 for ; Wed, 11 Dec 1996 14:16:36 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by margaux.inria.fr (8.7.6/8.7.3) with ESMTP id OAA17636 for ; Wed, 11 Dec 1996 14:16:36 +0100 (MET) Received: from nef.ens.fr (nef.ens.fr [129.199.96.12]) by concorde.inria.fr (8.7.6/8.7.1) with ESMTP id OAA27659 for ; Wed, 11 Dec 1996 14:16:35 +0100 (MET) Received: from vedette.ens.fr (vedette.ens.fr [129.199.130.1]) by nef.ens.fr (8.8.4/jtpda-5.1) with ESMTP id OAA24314 ; Wed, 11 Dec 1996 14:16:34 +0100 (MET) Received: from localhost (vouillon@localhost) by vedette.ens.fr (8.8.2/jb-1.1) id OAA24694 ; Wed, 11 Dec 1996 14:16:32 +0100 (MET) X-Authentication-Warning: vedette.ens.fr: vouillon owned process doing -bs Date: Wed, 11 Dec 1996 14:16:31 +0100 (MET) From: Jerome Vouillon X-Sender: vouillon@vedette Reply-To: Jerome Vouillon To: Hendrik Tews cc: caml-list@margaux.inria.fr Subject: Re: Questions about class types In-Reply-To: <199612101110.MAA11392@ithif18.inf.tu-dresden.de> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: weis Hello, > In ocaml I could hide all the additional objects in a module > implementation. But so far it is not possible to hide methods via > signature matching. It is definitively not possible to hide methods in a class. When a method is redefined, it must keep the same type. The reason is that other methods of the same class might invocate it, and thus expect it to have a certain type. But if a method were hidden, its previous type would also be hidden, and there would be no way to enforce a redefinition of this method to have the right type. > But I still don't understand the type error I got: > > Values do not match: > val newb : unit -> b > is not included in > val newb : unit -> < init : unit; .. > > > If b does not match < init : unit; .. > then the type cast in > > # let newb () : < init : unit; .. > = ((new b ()) : < init : unit; .. >) > > should produce an error. On the other side if the type cast is > valid, then the types should match. Type < init : unit; .. > is more general than type b = < init : unit; f : unit > (the ellipsis is an unamed type variable). So, your type cast produces no error (these two types can be unified), but you cannot expect a function of type unit -> b to be considered as having the more general type unit -> < init : unit; .. >. Regards, Jerome