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 LAA21222; Sun, 22 Sep 2002 11:30:10 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 LAA21211 for ; Sun, 22 Sep 2002 11:30:09 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from athlon.baretta.com (r-mi214-6a167.tin.it [62.211.4.167]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g8M9U7511300 for ; Sun, 22 Sep 2002 11:30:08 +0200 (MET DST) Received: from baretta.com (localhost.localdomain [127.0.0.1]) by athlon.baretta.com (Postfix) with ESMTP id 623F227399; Sun, 22 Sep 2002 11:39:36 +0200 (CEST) Message-ID: <3D8D8FD8.7020108@baretta.com> Date: Sun, 22 Sep 2002 11:39:36 +0200 From: Alessandro Baretta Organization: Baretta srl -- www.baretta.com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: it, en MIME-Version: 1.0 To: Jacques Garrigue , Ocaml Subject: Re: [Caml-list] Polymorphic methods and ellipsis References: <3D8BBCC4.1080906@baretta.com> <3D8C2F45.7080604@baretta.com> <20020922180759X.garrigue@kurims.kyoto-u.ac.jp> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Jacques Garrigue wrote: > From: Alessandro Baretta > >>At any rate, why does my technique not work? >> >>class salutation : object >> method greet : 'a. (#parent as 'a) -> string >>end = object >> method greet obj -> obj # foo ^ obj # bar >>end > > > You can see the above (and it is more or less type the same way) as > > class salutation0 = object > method greet obj -> obj # foo ^ obj # bar > end > > class salutation : object > method greet : 'a. (#parent as 'a) -> string > end = salutation0 > > So you see that your constraint is applied too late: salutation0 > itself is not typable. Oh! This is curious. You are telling me that the type constraints defined in the class type are applied once and for all *after* the class implementation has been typed? This would make sense after all, given that the class type and the class implementation are two distinct syntactic and semantic entities in O'Caml. This is not something I would have thought of on my own. > I though at some time of attempting to make this work, since something > like that is already done for recursive functions for instance, but > that's not regular. In fact, you would probably end up wanting to > write the implementation in the .ml and the interface in the .mli, and > this would not work anyway. This is not really a problem. I can live with locally applied constraints. I just did not realize why the my attempt did not work. Let me suggest another idea where you might better spend your time. I can write > let f x : 'a -> 'a = x but I cannot write method f x : 'a . 'a -> 'a = x I have to use the more cumbersome method f : 'a .'a -> 'a = fun x -> x The ability to type check correctly the first form of method declaration is an improvement I would appreciate. While not terriblly important, this is something that might be worth your time for some future release. > So, there is a deep problem about which constraints apply > where. The examples in the tutorial give you the way to do that > without ambiguity. > > Jacques Thank you very much for your explanations, Jacques. It is a pleasure to work with a language where I continually get to learn new, conceptually interesting ideas. I'd get bored to death otherwise. Alex ------------------- 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