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 XAA08556; Sun, 10 Feb 2002 23:32:23 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id XAA08601 for caml-list@pauillac.inria.fr; Sun, 10 Feb 2002 23:32:22 +0100 (MET) 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 OAA32265 for ; Sun, 10 Feb 2002 14:37:22 +0100 (MET) Received: from osiris.net-nono.com (ANice-102-1-3-150.abo.wanadoo.fr [193.253.57.150]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g1ADbLD20746 for ; Sun, 10 Feb 2002 14:37:21 +0100 (MET) Received: (from pagano@localhost) by osiris.net-nono.com (8.11.2/8.11.2) id g1ADeKC29561; Sun, 10 Feb 2002 14:40:20 +0100 Date: Sun, 10 Feb 2002 14:40:20 +0100 From: Bruno Pagano To: Warp Cc: caml-list@inria.fr Subject: Re: [Caml-list] Suggestion for overloaded operators Message-ID: <20020210144020.A29539@osiris.net-nono.com> References: <006801c1b233$83825ec0$0700a8c0@warp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <006801c1b233$83825ec0$0700a8c0@warp>; from warplayer@free.fr on Sun, Feb 10, 2002 at 02:04:45PM +0100 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sun, Feb 10, 2002 at 02:04:45PM +0100, 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 : > > (a :+ b) > The ':' is here to precise that we're using overloading , and a and b can be > of any type. ( let's say typea and typeb ) > The compiler will seek for a function named : > typea_add_typeb : typea -> typeb -> typer > and use it to implement the :+ operator. ( which have typer as result type ) > And so on... > > I think such a thing cannot be done with CamlP4 - because it doesn't know > about types - and I know that the ocaml team has lots of things to do , but > I was thinking that can be a quite good feature for futur updates. > > Warp > > ------------------- > 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 Hello, what about polymorphism ? assume following declarations : let (:+) x y = x + y let (:+) x y = x +. y we define the overloaded operator :+ (respectively for int and for float) what about the following declaration : let f x y = x :+ y ;; Is f overloaded too ? f has not the colon symbol ! Is this declaration forbidden ? why ! I think that overloading is not compatible with type inference ? Bruno Pagano PS: Perhaps, type inference is no more relevant with modules and objects and should disappear ! ------------------- 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