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 OAA32014; Sun, 10 Feb 2002 14:35:48 +0100 (MET) 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 OAA32244 for ; Sun, 10 Feb 2002 14:35:47 +0100 (MET) Received: from nef.ens.fr (nef.ens.fr [129.199.96.32]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g1ADZkr08323 for ; Sun, 10 Feb 2002 14:35:46 +0100 (MET) Received: from clipper.ens.fr (clipper-gw.ens.fr [129.199.1.22]) by nef.ens.fr (8.10.1/1.01.28121999) with ESMTP id g1ADZkp25243 ; Sun, 10 Feb 2002 14:35:46 +0100 (CET) Received: from localhost (frisch@localhost) by clipper.ens.fr (8.9.2/jb-1.1) id OAA17725 ; Sun, 10 Feb 2002 14:35:46 +0100 (MET) Date: Sun, 10 Feb 2002 14:35:46 +0100 (MET) From: Alain Frisch To: Warp cc: OCaml Subject: Re: [Caml-list] Suggestion for overloaded operators In-Reply-To: <006801c1b233$83825ec0$0700a8c0@warp> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sun, 10 Feb 2002, Warp wrote: > Helo. > One of missing thing in Ocaml is the possibility to overload the operators > such as + - / * = (by overloading, i mean : defining such operators for > other types than -int- ).... > Here's a syntactic proposal to enable this feature : You say nothing about the typing of static overloading (interaction with polymorphism and type inference), and this is the crux of the matter. What type would you give to: fun a b -> a :+ b ? This expression has many possible types, and no best one. Even when the context could allow to statically resolve the overloading, this may be beyond the current type inference algorithm. For instance: fun a b -> let r = a :+ b in a + b + r The end of the expression allows to deduce that a and b are int, but when :+ is typed, this information is not yet available. A simple minded solution is to require that enough type information is available to resolve the overloading at the point where the algorithm encounters it. This is very similar to the patch I posted to this list about overloading of record labels, and the same arguments against it apply as well. Maybe you should have a look at G'Caml: http://pauillac.inria.fr/~furuse/generics/ -- Alain ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr