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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Brian Hurt <bhurt@j...>
Subject: Re: [Caml-list] Operator overloading
Jon Harrop wrote:

>On Thursday 08 March 2007 17:54, Brian Hurt wrote:
>  
>
>>Roland Zumkeller wrote:
>>    
>>
>>>Wasn't there a more or less good reason for OCaml *not* to support
>>>operator overloading?
>>>      
>>>
>>Yes.  Ocaml has modules and functors.  IMHO, any time you thing "boy,
>>it'd be really nice to use operator overloading here", you should use a
>>module and a functor instead.
>>...
>>    
>>
>
>For me, operator overloading is about clarity. In the absence of operator 
>overloading, you cannot regain the lost clarity using modules and functors.
>  
>
Hmm.  My experience from C++ was that operator overloading results in a 
net *loss* in clarity of the code.  For every time I've seen operator 
overloading done correctly, I've seen it abused at least twice, probably 
more often.  And this is even ignoring the use of << and >> in IO.  By 
abused, I mean "used in a way that violates the numerical implications 
of the operator".

There are also the case of bugs introduced by operator overloading.  For 
example, in C++, this sucker has bitten me:
       int i = 10;
       cout << i << 2;

The problem here is the two different meanings of <<. 

Brian