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: [Caml-list] Suggestion for overloaded operators
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