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 MAA29850; Sat, 7 Jun 2003 12:59:14 +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 MAA29662 for ; Sat, 7 Jun 2003 12:59:13 +0200 (MET DST) Received: from sockmel.bononia.it (sockmel.bononia.it [193.201.40.5]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h57AxCH13734 for ; Sat, 7 Jun 2003 12:59:12 +0200 (MET DST) Received: from fistandantilus.takhisis.org (sockmel.bononia.it [193.201.40.5]) by sockmel.bononia.it (Postfix) with ESMTP id 9C62256EF0 for ; Sat, 7 Jun 2003 12:59:11 +0200 (CEST) Received: by fistandantilus.takhisis.org (Postfix, from userid 3148) id 2B3DF27429F; Sat, 7 Jun 2003 12:59:11 +0200 (CEST) Date: Sat, 7 Jun 2003 12:59:11 +0200 From: Stefano Zacchiroli To: "caml-list@inria.fr" Subject: Re: easy print and read (was: [Caml-list] Why are arithmetic functions not polymorph?) Message-ID: <20030607105911.GA13315@fistandantilus.takhisis.org> Mail-Followup-To: "caml-list@inria.fr" References: <20030606124626.A27959@pauillac.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.4i X-Spam: no; 0.00; bononia:01 caml-list:01 brogoff:01 generic:01 inferred:01 gcaml:01 inference:01 0700,:01 speakeasy:01 int:01 arithmetic:01 06,:02 ambiguous:02 float:02 address:96 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, Jun 06, 2003 at 09:40:16AM -0700, brogoff@speakeasy.net wrote: > BTW, someone (Brian Hurt?) brought up a nice simple example of where the > current generic polymorphism seems a bit weak > > generic one = | int => 1 | float => 1.0 ;; > generic two = | int => 2 | float => 2.0 ;; > generic plus = | float -> float -> float => (+.) | int -> int -> int => (+);; > > plus one two;; (* Can't determine plus without at least one type annotation *) > > and it would be nice if in such situations the correct plus could be inferred. I haven't tried GCaml, I've just read the README you pointed out and it seems to address your issue: How about "plus one one"? There are two possibilities: adding integer 1's or float 1.0's? In such ambiguous situation, the type inference algorithm takes the first one defined as defaults: plus one one is typed as (plus : int -> int -> int) (one : int) (one : int) I don't think that "plus one two" is typed differently ... Cheers. -- Stefano Zacchiroli -- Master in Computer Science @ Uni. Bologna, Italy zack@{cs.unibo.it,debian.org,bononia.it} - http://www.bononia.it/zack/ " I know you believe you understood what you think I said, but I am not sure you realize that what you heard is not what I meant! " -- G.Romney ------------------- 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