Version française
Home     About     Download     Resources     Contact us    
Browse thread
stl?
[ 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@s...>
Subject: Re: [Caml-list] stl?


On Wed, 4 Mar 2009, Martin Jambon wrote:

> Brian Hurt wrote:
>>
>>
>> On Tue, 3 Mar 2009, Jon Harrop wrote:
>>
>>> Functors give
>>> you the same capability in OCaml but they are rarely used precisely
>>> because
>>> the functionality is not very useful.
>>
>> I think I disagree with this.  I think functors aren't used very much in
>> Ocaml because:
>> 1) They're a big, scary name, and
>> 2) They're slightly less efficient.
>
> Functors are not used very much because they are not needed very often. 
> OCaml is a free market.

I don't think they're used anywhere nearly as often as they could 
profitably be employed, judging from Haskell's use of type classes.

>
> All sorts of reusable algorithms on arbitrary data can be nicely 
> implemented using functors, without more difficulty than the specialized 
> versions of the same algorithm. But do you often implement cool 
> algorithms that work on arbitrary types? Not me. Certainly less than 5% 
> of the time. Most of the time we have to deal with the brutality of the 
> real world, which is all bytes and strings.

I agree.  Going back to the original topic of this thread, my experience 
with C++ is that the vast majority of the time templates are used, Ocaml 
would simply use polymorphic types.  For example, you don't need functors 
to write a list library.  I'd guess 90-95% of the template uses I've seen 
in C++ have been just to do the equivalent of 'a list.

Brian