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.3 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 65192BC1E for ; Wed, 4 Mar 2009 00:37:19 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnEBAGNOrUnUnwckjmdsb2JhbACCHZJqAQEBAQkLCAkPBsIOhAgG X-IronPort-AV: E=Sophos;i="4.38,297,1233529200"; d="scan'208";a="23817684" Received: from relay.ptn-ipout02.plus.net ([212.159.7.36]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 04 Mar 2009 00:37:19 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ar8EAGNOrUnUnw4S/2dsb2JhbACCHdU2hAgG Received: from pih-relay05.plus.net ([212.159.14.18]) by relay.ptn-ipout02.plus.net with ESMTP; 03 Mar 2009 23:37:18 +0000 Received: from [87.112.234.120] (helo=leper.local) by pih-relay05.plus.net with esmtp (Exim) id 1LeeAo-0006Q9-4w for caml-list@yquem.inria.fr; Tue, 03 Mar 2009 23:37:18 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] stl? Date: Tue, 3 Mar 2009 23:42:39 +0000 User-Agent: KMail/1.9.9 References: <91a2ba3e0903031340wcdc976cp52522eb35f7ccb73@mail.gmail.com> In-Reply-To: <91a2ba3e0903031340wcdc976cp52522eb35f7ccb73@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200903032342.39527.jon@ffconsultancy.com> X-Plusnet-Relay: d5105c6c935bfd0d7778301523a98296 X-Spam: no; 0.00; stl:01 polymorphism:01 stl:01 stepanov:01 iirc:01 o'caml:01 ocaml:01 ocaml:01 trade-offs:01 higher-order:01 bindings:01 bindings:01 functors:01 2009:98 frog:98 On Tuesday 03 March 2009 21:40:11 Raoul Duke wrote: > hi, > > the caml archives show discussion around C++ polymorphism wrt STL > (since Stepanov iirc said that C++ was the only language which > supported what he needed to let him implement his generic programming) > but i didn't yet see anywhere a concrete implementation or mapping > from C++ STL to O'Caml. > > i'm just trying to get my head around what it might look like, and > if/how it might be useful. (it just bugs me that somebody can claim > that C++ is the /only/ language that could do it -- maybe the real > quote implied "mainstream" or something. apparently Ada wasn't up to > snuff http://www.sgi.com/tech/stl/drdobbs-interview.html) I spent many years programming in C++ before I learned OCaml and my first reaction was to try to use classes for everything and to try to reinvent the STL in OCaml. However, the result cannot be useful because the STL simply represents a poor choice of trade-offs. For example, higher-order functions like fold and map are extremely useful, particularly when their function argument is a closure, but that is too tedious to be useful in the STL whereas the ability to reuse a single "find" function over many different data structures is easy in the STL but useless in practice because you almost always know what data structure to use before you write the code (so you hard code List.find) and, if you don't, you just rename a module and use that instead (module Bindings = List ... Bindings.find) so there is only one code location to update. Functors give you the same capability in OCaml but they are rarely used precisely because the functionality is not very useful. -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e