Version française
Home     About     Download     Resources     Contact us    
Browse thread
[OSR] OCaml Standard Recommandation Process
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Loup Vaillant <loup.vaillant@g...>
Subject: Re: [Caml-list] [OSR] OCaml Standard Recommandation Process
2008/1/28, Brian Hurt <bhurt@janestcapital.com>:
> I *hate* operator overloading.  My experience in C++ is for every time
> this feature is used legitimately (i.e. to implement complex numbers or
> whatever), it's abused 10 times- and that's ignoring C++'s use of the
> bit shift operators << and >> for I/O, and the use of + for string
> concatentation, both of which I'd argue really should be considered
> abuses, as far as I'm concerned.  And this is ignoring the difficulty of
> type inference in the presence of overloaded operators.
>
> The best way to handle this IMHO is Haskell-style type classes.  Which
> solves the whole type inference problem, and rules most of what I
> consider abuses of operator overloading (for example, if you have a '+'
> operator, you also have to have a '*' operator- and what is "foo" *
> "bar"?).  But this is a very non-trivial change to the language.

Err, are you really suggesting type classes to be added in Ocaml?
Doing that properly would require to change the whole standard
library, breaking havoc in every single Ocaml program, even the
simplest
print_string "Hello World";;

I also heard that the current type checker is "quite" complicated
(labels, variants, objects...).  Type classes fits well with a naked
Hindley-Milner type system, but how would it interact with the extra
Ocaml features?

Finally, it may make some type annotations mandatory, which may be
viewed a unacceptable. (I'm not sure of this one, though.)

Maybe type classes should be added, but I'm afraid they can't. :-(

Loup