Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Why are arithmetic functions not polymorph?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: John Max Skaller <skaller@o...>
Subject: Re: [Caml-list] Why are arithmetic functions not polymorph?
Brian Hurt wrote:

> I don't want to turn this into a C++ 
> flamefest (had one of those already this week), but in my experience 
> operator overloading is *really* *really* bad.

Not doubt because you had to work on someone else's
stupid code.

There is a clear an obvious need for overloading
aritmetic operators in Ocaml, now it has a reasonably
rich set of arithmetic types (including Big_int etc).
Another needed overload is 'print' (to print some
representation of a value which might be used in
a diagnostic).

There are fairly obvious rules about not
*overusing* a facility. C++ programmers, alas,
are prone to stretching the meager technology
available to them to the limit. One comment I read
on (or was it Freshmeat) about Ocaml
was who ugly it was to write

		print_endline (string_of_int i)

compared to
		cout << i << endl;

To be truthful such longwindedness often
obscures my program logic: the case they make
isn't really sound, but it is not entirely stupid either.

Of course, there is a distinction between
convenience (+ for all arithmetic types),
and dependence (dependent name lookup in templates).
The later is an abuse the *forces* complex overloads
to be defined (so that templates work).

John Max Skaller,
snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia.

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: