From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 7256FBBC4 for ; Wed, 4 Mar 2009 07:19:39 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApECACOsrUnYi40JmWdsb2JhbACBTpM5AQEBAQEICwoHEcEwhAgG X-IronPort-AV: E=Sophos;i="4.38,299,1233529200"; d="scan'208";a="23823720" Received: from mail-out9.nyct.net (HELO mail.nyct.net) ([216.139.141.9]) by mail3-smtp-sop.national.inria.fr with ESMTP; 04 Mar 2009 07:19:38 +0100 Received: from beast.local (pool-96-250-132-59.nycmny.east.verizon.net [96.250.132.59]) (authenticated bits=0) by mail.nyct.net (8.14.2/8.14.1) with ESMTP id n246JD9Y057729 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=NO); Wed, 4 Mar 2009 01:19:15 -0500 (EST) (envelope-from bhurt@spnz.org) Date: Wed, 4 Mar 2009 01:18:46 -0500 (EST) From: Brian Hurt X-X-Sender: bhurt@beast To: Martin Jambon Cc: Jon Harrop , caml-list@yquem.inria.fr Subject: Re: [Caml-list] stl? In-Reply-To: <49ADF140.8070409@ens-lyon.org> Message-ID: References: <91a2ba3e0903031340wcdc976cp52522eb35f7ccb73@mail.gmail.com> <200903032342.39527.jon@ffconsultancy.com> <49ADF140.8070409@ens-lyon.org> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Spam: no; 0.00; stl:01 functors:01 ocaml:01 functors:01 ocaml:01 haskell's:01 brutality:01 polymorphic:01 wrote:01 wrote:01 caml-list:01 precisely:01 strings:01 jambon:01 algorithm:01 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