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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 08C8DBBC4 for ; Tue, 3 Mar 2009 23:32:10 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqQBAEE+rUmArgVgkWdsb2JhbACMaId/AQEBAQkLCgcRBMJXB4N/Bg X-IronPort-AV: E=Sophos;i="4.38,297,1233529200"; d="scan'208";a="22001942" Received: from expredir5.cites.uiuc.edu ([128.174.5.96]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 03 Mar 2009 23:32:10 +0100 Received: from axyr (aryx.cs.uiuc.edu [128.174.236.106]) by expredir5.cites.uiuc.edu (8.14.2/8.14.2) with ESMTP id n23MW6Tl014013; Tue, 3 Mar 2009 16:32:06 -0600 (CST) To: Raoul Duke Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] stl? References: <91a2ba3e0903031340wcdc976cp52522eb35f7ccb73@mail.gmail.com> From: Yoann Padioleau Date: Tue, 03 Mar 2009 16:31:55 -0600 In-Reply-To: <91a2ba3e0903031340wcdc976cp52522eb35f7ccb73@mail.gmail.com> (Raoul Duke's message of "Tue\, 3 Mar 2009 13\:40\:11 -0800") Message-ID: <87zlg2z19g.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=us-ascii X-Spam: no; 0.00; stl:01 polymorphism:01 stl:01 stepanov:01 iirc:01 o'caml:01 stepanov:01 unboxed:01 ocaml:01 'int:01 integers:01 ocaml:01 arrays:01 hash:01 iterator:01 Raoul Duke writes: > 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 don't know what are the Stepanov requirements, but C++ can do unboxed collections like list, which OCaml can not provide I think. a 'int list' has boxed integers in OCaml. Also, a maybe good thing with STL is that you can write a single 'find' or 'sort' function that will work for every kind of collections (list, arrays, map, hash, etc) by using the indirect iterator idiom, without the penalty of dynamic dispatch solutions. I am not sure OCaml can do that too. The question is do we really need those 2 things ? I've worked a little bit with C++ using unboxed objects, that is without introducing pointers (similar to boxing) in templates, like list
instead of list, and passing them as value in parameters, or returning them, and it was far less efficient because there was lots of copy, and you could not use then virtual method on them. So in the end the C++ programmer I thing manually re-introduce boxing when using STL if he wants good performance, and he can not really rely either on the default copy/equal implementation provided by those templates. So, yes STL makes it possible to do things, but programmers don't want them, or only in very few cases where one need extreme performance. > > sincerely. > > _______________________________________________ > 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