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 IAA18934; Tue, 9 Jul 2002 08:23:10 +0200 (MET DST) 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 IAA19249 for ; Tue, 9 Jul 2002 08:23:09 +0200 (MET DST) Received: from night.its.uiowa.edu (night.its.uiowa.edu [128.255.56.106]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g696N8H02912 for ; Tue, 9 Jul 2002 08:23:08 +0200 (MET DST) Received: from uiowa.edu (host38-92.uihc.uiowa.edu [129.255.38.92]) by night.its.uiowa.edu (8.11.6/8.11.6/ns-mx-1.14) with ESMTP id g696N6l140328 for ; Tue, 9 Jul 2002 01:23:06 -0500 Message-ID: <3D2A814A.5020303@uiowa.edu> Date: Tue, 09 Jul 2002 01:23:06 -0500 From: Brian Smith User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1a) Gecko/20020611 X-Accept-Language: en-us, en MIME-Version: 1.0 To: OCaml Mailing list Subject: Re: [Caml-list] Polymorphic methods (syntax) References: <3D28E9F8.5020308@uiowa.edu> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk My original problem has already been fixed in the latest CVS version by Jacques. And, I found out that there is some documentation about polymorphic methods on the O'Labl website. But, now I have another question, this time about syntax. Consider, # class ['a] example = object method id x : 'a = x end;; Now, let's say I want to move the type variable from the class to the method. Intuitively, I expect that O'Caml could use this definition: # class example = object method id x = x end;; Some type variables are unbound in this type: class example : object method id : 'a -> 'a end The method id has type 'a -> 'a where 'a is unbound I would hope that O'Caml would infer that the type of the method x is ('a -> 'a) for all 'a. But, I know that Jacques has already said that type inference of this type is not practical and so type annotations are needed (Although, O'Caml actually does infer the correct type in this situation, it just disallows it). With that in mind, my next inutition is to try: # class example = object method ['a] id x : 'a = x end;; or equivalently: # class example = object method ['a] id (x : 'a) = x end;; Notice, I took the type parameter from the polymorphic class and just moved it down to the method. But, currently this doesn't work either. I propose that, if practical, this syntax be made to work. The benefits are (1) symmetry with the syntax used for polymorphic classes, and (2) less verbosity. As a comparison, in the current syntax (CVS version of O'Caml), the definition would be: # class example = object method id : 'a. 'a -> 'a = fun x -> x end;; What do you think? - Brian ------------------- 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