Version française
Home     About     Download     Resources     Contact us    
Browse thread
RE: [Caml-list] Operator overloading
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Till Varoquaux <till.varoquaux@g...>
Subject: Re: [Caml-list] Operator overloading
Hum...

Instead of proving once again Godwin's law we might want to use
constructive criticism (even though I also tend to flame more than my
share)...

There have been many articles relating type classes and ML module
system. Lambda the Ultimate has link to quite a share of them.
Swapping type classes for modules forces you to be more explicit and
verbose. Indeed you would have to wrap your code in a functor whenever
you want ad-hoc polymorphism (aka overloading) to occur. This can
prove quite cumbersome. Haskell relies heavily on type classes, monads
would be much more painful if you had to wrap them in a functor.

Overloading, however, does come with a cost: the compiler cannot get
rid of all type information: sometime (e.g. separate compilation) the
right monomorphic function can only be done dynamically.

G'Caml brings extensional polymorphism (types as first class values)
to OCaml. Extensional polymorphism allows run time type introspection
thus allowing overloading...  whether you like it or not is a matter
of personal taste.

Till

P.S. FYI I happen to like type classes and exceptions. I do know there
are also good reasons not to and I respect other opinions.

On 3/8/07, Brian Hurt <bhurt@janestcapital.com> wrote:
> Tom wrote:
>
> >
> > Albeit Brian Hurt's comment about operator overloading making more
> > harm than good in C++, I believe that overloading simply has to be
> > used appropriately - it's like saying pointers are bad because they
> > can introduce memory leaks and null references, and division is bad
> > because it can raise Division_by_zero exceptions.
> >
> So maybe we should introduce pointers into Ocaml?
>
> Brian
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>