Browse thread
[Caml-list] Suggestion for overloaded operators
-
Warp
- Alain Frisch
- Tom
- Bruno Pagano
- Francois Pottier
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Bruno Pagano <bpagano@f...> |
| Subject: | Re: [Caml-list] Suggestion for overloaded operators |
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