Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Why are arithmetic functions not polymorph?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Ville-Pertti Keinonen <will@e...>
Subject: Re: [Caml-list] Why are arithmetic functions not polymorph?

> SML has a kind of operator overloading, but I don't know the details.

They're overloaded up to the point of type inference, after which they 
become integer operations.  I think it's better not to have something 
as inconsistent as SML.

This works:

- op +;
val it = fn : int * int -> int
- op + (1.0, 2.0);
val it = 3.0 : real

This doesn't:

- val myadd = op +;
val myadd = fn : int * int -> int
- myadd (1.0, 2.0);

-------------------
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