English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2002-02-10 (13:09)
From: Warp <warplayer@f...>
Subject: [Caml-list] Suggestion for overloaded operators
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.


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