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=1.6 required=5.0 tests=AWL,DNS_FROM_RFC_POST autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 4DC72BBC4 for ; Wed, 4 Mar 2009 17:48:37 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ak0BABg/rkmArgWokWdsb2JhbACMa4gXAQEBAQkLCgcRBMNFB4QBBg X-IronPort-AV: E=Sophos;i="4.38,301,1233529200"; d="scan'208";a="36092822" Received: from expredir7.cites.uiuc.edu ([128.174.5.168]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 04 Mar 2009 17:48:36 +0100 Received: from axyr (aryx.cs.uiuc.edu [128.174.236.106]) by expredir7.cites.uiuc.edu (8.14.2/8.14.2) with ESMTP id n24GmULD016713; Wed, 4 Mar 2009 10:48:30 -0600 (CST) To: Mikkel =?utf-8?Q?Fahn=C3=B8e_J=C3=B8rgensen?= Cc: Raoul Duke , caml-list@yquem.inria.fr Subject: Re: [Caml-list] stl? References: <91a2ba3e0903031340wcdc976cp52522eb35f7ccb73@mail.gmail.com> From: Yoann Padioleau Date: Wed, 04 Mar 2009 10:48:18 -0600 In-Reply-To: ("Mikkel =?utf-8?Q?Fahn=C3=B8e_J=C3=B8rgensen=22's?= message of "Wed\, 4 Mar 2009 17\:35\:56 +0100") Message-ID: <87eixdz12l.fsf@aryx.cs.uiuc.edu> User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; stl:01 mikkel:01 rgensen:01 mikkel:01 polymorphism:01 stl:01 stepanov:01 iirc:01 o'caml:01 stepanov:01 ocaml:01 unboxing:01 functors:01 ocaml:01 beginner's:01 Mikkel Fahn=C3=B8e J=C3=B8rgensen writes: > 2009/3/3 Raoul Duke : >> 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. > > As I recall, Stepanov did originally work containers in Lisp or > similar, but realized this would never help "real world" programmers. > The C++ template is far more powerful than originally anticipated and > Stepanov took advantage of that. Clearly, the choice of C++ has > affected the design of STL, so it would be pointless to try to port > STL directly to OCaml. > > In fact, I think that OCamls basic Array, List, containers and > polymorphic algorithms does exactly what Stepanov intended to do, I don't think so. I've read the last "history of C++" by Stroustrup in HOPL-III, who discusses quite a lot about the STL and Stepanov, and from what I remember unboxing was a big issue and having "generic" (which is slightly different from polymorphic) algorithms without introducing performance penalty that object-solution has with dynamic dispatch was also a big issue. Those people are not stupid. They know about ML. C++ even has some advanced dependent types in some way (array). I hate C++ with a passion, but the C++ designers are far from stupid. > without having to introduce Functors or other overhead. However, OCaml > could do with a more precisely defined container duck typing interface > (not an interface just convention) which I think will happen with > Batteries. I think perhaps OCaml could have a library of algorithms > that are not specific to one container type, but again that requires > better duck typed containers, and perhaps it is just better and more > efficient to implement the most important operations for each > container type instead of trying to generalized the entire world. > > Scripting languages were not so hot at the time, short of Perl, but > Ruby would easily fit well into the STL idea, just like Lisp also did. No, because of the performance penalty of dispatch. Again, those C++ designer guys have strong requirments on performance. Most of us can live with those overheads, but apparently they don't. > There was a discussion by STL insiders about wether algorithms (simple > example is the min function) should be template parameterized. They > ended up not having explicit type arguments because this was much > simpler to work with. Containers (like vector) have type arguments > because they were necessary in C++. > > As to whether STL is well designed or not, fast or not, I think STL at > the time solved a great problem. Of course you could do something > faster, but often a map or set would be just what needed, just like > OCamls current Map and Set is usually good enough. Sure (when they are defunctorized ... :) ) > > Mikkel > > _______________________________________________ > 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