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] About overloading( + +. and <)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-07-03 (07:30)
From: Jean-Christophe Filliatre <Jean-Christophe.Filliatre@l...>
Subject: Re: [Caml-list] About overloading( + +. and <)

temofey writes:
 > But compare operators like "<", ">" is the same for Integer, Float,
 > String. Are they overload? Is this contradiction in terms?

=, < and > are not overloaded, but polymorphic. It means they can be
applied to any two values of the same type, for any type (base types
but also user defined types like tuples, records, recursive 
types, etc.) except functional types (on which we don't know how to
compare values). You may have a look at
byterun/compare.c in ocaml sources to see how this comparison is defined.

It couldn't be the same for arithmetic operations (plus, minus, etc)
because we don't know how to define them on types other than int and

Jean-Christophe Filliatre
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