Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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
float.

-- 
Jean-Christophe Filliatre
  mailto:Jean-Christophe.Filliatre@lri.fr
  http://www.lri.fr/~filliatr
-------------------
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