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 XAA30001; Fri, 23 May 2003 23:01:34 +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 XAA30072 for ; Fri, 23 May 2003 23:01:32 +0200 (MET DST) Received: from epexch01.qlogic.org ([63.170.40.3]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h4NL1VT01633 for ; Fri, 23 May 2003 23:01:32 +0200 (MET DST) Received: from epmailtmp.qlogic.org ([10.20.33.254]) by epexch01.qlogic.org with Microsoft SMTPSVC(5.0.2195.5329); Fri, 23 May 2003 15:59:36 -0500 Received: from [10.20.33.146] ([10.20.33.146]) by epmailtmp.qlogic.org with Microsoft SMTPSVC(5.0.2195.4905); Fri, 23 May 2003 15:59:36 -0500 Date: Fri, 23 May 2003 16:15:35 -0500 (CDT) From: Brian Hurt X-X-Sender: Reply-To: Brian Hurt To: cc: Brian Hurt , David Monniaux , hermanns , "caml-list@inria.fr" Subject: Re: [Caml-list] Why are arithmetic functions not polymorph? In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-OriginalArrivalTime: 23 May 2003 20:59:36.0488 (UTC) FILETIME=[37ECA280:01C3216E] X-Spam: no; 0.00; qlogic:01 caml-list:01 brogoff:01 haskell:01 gcaml:01 generic:01 oftentimes:01 arbitrarily:01 inlined:01 inference:01 camlp:01 accessor:01 hashtbl:01 lookups:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, 23 May 2003 brogoff@speakeasy.net wrote: > I understand the difference between operator redefinition, which OCaml and > SML have, and user defined overloading, which neither has, but which can be > found in Haskell and Clean (sort of, through type classes) and C++ and Ada. > > I actually think overloading can be *really* *really* good. The problem, or > rather, one of the many problems, with C++ IMO is that it has overloading and > implicit conversions of types. That's a bad combination. > > One nice thing about GCaml is that it shouldn't bother people like you who > dislike overloading. The overloading is fairly explicit and closed world. > It gracefully handles the most important, very simple cases, and sneaks > in the ability to type a much wider range of functions than can be typed now. > You should at least take a look at the README in the prototype to get an idea of > what I mean here. OK. I'm reading the readme. First off, congratulations, you're dodging a lot of the bullets that C++ didn't. Here's a question. Consider the following code: generic one = | int => 1 | float => 1.0 generic two = | int => 2 | float => 2.0 generic plus = | int -> int -> int = (+) | float -> float -> float = (+.) plus one two;; What's the result? Is it the int 3, or the float 3.0? Another problem already arises with the generic (aka overloaded) comparisons- you oftentimes need to arbitrarily specify types in order to replace the expensive call to the generic compare with a much cheaper inlined type-specific compare. If you start having to specify types a lot more often, that reduces the advantage of having type inference. > New operators are not sufficient, and SML is more powerful in it's ability to > define new operators than OCaml (minus CamlP4) is. Yeah- I'd like to be able to define accessor operators somehow. Say being able to define $[ ] as hashtbl lookups, so that h$[3] ==> Hashtbl.find h 3. 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