From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA15553; Thu, 5 Feb 2004 14:45:38 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA16642 for ; Thu, 5 Feb 2004 14:45:37 +0100 (MET) Received: from avalon.ens-lsh.fr (mailhost.ens-lsh.fr [193.51.131.2]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id i15Djbv28077 for ; Thu, 5 Feb 2004 14:45:37 +0100 (MET) Received: from avalon.ens-lsh.fr (localhost [127.0.0.1]) by avalon.ens-lsh.fr (8.12.8/8.12.8) with ESMTP id i15Ei29g000552 for ; Thu, 5 Feb 2004 14:44:02 GMT Received: from ens-notes1.ens-lsh.fr (ens-notes1.ens-lsh.fr [10.2.1.44]) by avalon.ens-lsh.fr (8.12.8/8.12.8) with ESMTP id i15EhrTG000520 for ; Thu, 5 Feb 2004 14:44:01 GMT Received: from mostha ([10.3.20.31]) by ens-notes1.ens-lsh.fr (Lotus Domino Release 5.0.10) with SMTP id 2004020514452262:1920 ; Thu, 5 Feb 2004 14:45:22 +0100 Date: Thu, 5 Feb 2004 14:45:06 +0100 From: Damien To: caml-list@inria.fr Subject: Re: [Caml-list] functors and objects Message-Id: <20040205144506.57a47fc7.Damien.Pous@ens-lyon.fr> In-Reply-To: <20040205181845V.garrigue@kurims.kyoto-u.ac.jp> References: <20040203190635.6cc61ff0.Damien.Pous@ens-lyon.fr> <20040204115745J.garrigue@kurims.kyoto-u.ac.jp> <20040205095512.62ef577d.Damien.Pous@ens-lyon.fr> <20040205181845V.garrigue@kurims.kyoto-u.ac.jp> Organization: mosthagloups X-Mailer: Sylpheed version 0.9.6claws (GTK+ 1.2.10; i386-pc-linux-gnu) Mime-Version: 1.0 X-MIMETrack: Itemize by SMTP Server on ens-notes1/ENS-LSH(Release 5.0.10 |March 22, 2002) at 05/02/2004 14:45:22, Serialize by Router on ens-notes1/ENS-LSH(Release 5.0.10 |March 22, 2002) at 05/02/2004 14:45:32, Serialize complete at 05/02/2004 14:45:32 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Loop: caml-list@inria.fr X-Spam: no; 0.00; damien:01 damien:01 ens-lyon:01 caml-list:01 functors:01 2004:99 jacques:01 covariant:01 unsound:01 soundness:01 ellipsis:01 ellipsis:01 functor:01 struct:01 covariant:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, 05 Feb 2004 18:18:45 +0900 Jacques Garrigue wrote: > Because instanciation/specialization only works for values, not for > types. > This is reasonable enough: once you have defined a type, you may use > it both in covariant and contravariant positions, so allowing to > specialize it would be unsound. > (So, yes, in the long run this is a soundness problem.) I don't see the point :-( module type O = sig type " t :> o " end can be read as module type O = sig type ellipsis (* abstract *) type t = " " end therefore, a functor F(M: O) cannot create objects of type t without the help of M. module F(M: O) = struct (* correct invariant use *) let l: M.t list ref = ref [] (* correct covariant use *) let get: unit -> M.t list = fun () -> !l (* correct contravariant use *) let add: M.t -> unit = fun o -> l := o : !l (* unsound has type `unit -> o' but not `unit -> M.t' *) let unsound() = new object method react = () end end where is it wrong ? damien ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners