Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Suggestion for overloaded operators
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Warp <warplayer@f...>
Subject: Re: [Caml-list] Suggestion for overloaded operators
> 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)

here, you can't do that because :+ is not an operator.

let int_add_int x y = x + y
let float_add_float x y = x +. y


> what about the following declaration :
>
> let f x y = x :+ y ;;

f : 'a -> 'b -> 'c
and assume that a function called   typea_add_typeb exists and returns a 'c
type.

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

I don't know, but this thread should answer to that question.

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