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.2 required=5.0 tests=AWL,SPF_NEUTRAL 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 F004DBBC4 for ; Wed, 4 Mar 2009 15:24:26 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiUFAFIerklDWxLCaWdsb2JhbACBTpMzFAQiBLJbhzOITIQIBg X-IronPort-AV: E=Sophos;i="4.38,301,1233529200"; d="scan'208";a="36083188" Received: from ip67-91-18-194.z18-91-67.customer.algx.net (HELO server1.bertec.net) ([67.91.18.194]) by mail4-smtp-sop.national.inria.fr with ESMTP; 04 Mar 2009 15:24:07 +0100 Received: from kuba-laptop.bertec.net (kuba-laptop.bertec.net [192.168.2.48]) by server1.bertec.net (Postfix) with ESMTP id A4D9410575C for ; Wed, 4 Mar 2009 09:24:05 -0500 (EST) Message-Id: <8DE9FCF3-A2FE-4CA7-957F-000F6854D5BF@osu.edu> From: Kuba Ober To: caml-list@yquem.inria.fr In-Reply-To: <87zlg2z19g.fsf@aryx.cs.uiuc.edu> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Subject: Re: [Caml-list] stl? Date: Wed, 4 Mar 2009 09:24:05 -0500 References: <91a2ba3e0903031340wcdc976cp52522eb35f7ccb73@mail.gmail.com> <87zlg2z19g.fsf@aryx.cs.uiuc.edu> X-Mailer: Apple Mail (2.930.3) X-Spam: no; 0.00; stl:01 stl:01 stepanov:01 unboxed:01 ocaml:01 'int:01 integers:01 ocaml:01 unboxed:01 pointers:01 semantics:01 const:01 read-only:01 pointer:01 cheers:01 >> 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. > [...] > > 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 I think those are usually (or can be) implemented with copy-on-write semantics. Heck, if the objects are large, you can have specialized versions which use hardware-assisted copy-on-write. This is pretty much how data structures in Qt work, say when you pass QString around. While people usually pass a reference to a const QString as a read-only parameter, it costs no more to pass QString by value -- QString won't copy much besides a pointer or two, and it's a fairly small and simple class, as far as copy construction goes. Cheers, Kuba