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.2 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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id D17E8BBC4 for ; Sat, 4 Apr 2009 11:13:59 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjcDAMHB1knCpx6vi2dsb2JhbACWJgEBAQoLChi2Z4QPBg X-IronPort-AV: E=Sophos;i="4.39,323,1235948400"; d="scan'208";a="23933436" Received: from smtpka.univ-orleans.fr (HELO ka.univ-orleans.fr) ([194.167.30.175]) by mail2-smtp-roc.national.inria.fr with ESMTP; 04 Apr 2009 11:13:59 +0200 Received: from smtps.univ-orleans.fr (localhost [127.0.0.1]) by ka.univ-orleans.fr (Postfix) with ESMTP id A415512AD6D; Sat, 4 Apr 2009 11:13:59 +0200 (CEST) Received: from [192.168.0.12] (ras75-4-82-235-58-110.fbx.proxad.net [82.235.58.110]) by smtps.univ-orleans.fr (Postfix) with ESMTP id B369136E60; Sat, 4 Apr 2009 11:14:00 +0200 (CEST) Subject: Re: [Caml-list] Strings From: David Rajchenbach-Teller To: Jon Harrop Cc: caml-list@yquem.inria.fr In-Reply-To: <200904031256.33357.jon@ffconsultancy.com> References: <200904031256.33357.jon@ffconsultancy.com> Content-Type: text/plain Date: Sat, 04 Apr 2009 11:14:34 +0200 Message-Id: <1238836474.6250.11.camel@Blefuscu> Mime-Version: 1.0 X-Mailer: Evolution 2.12.1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ens-lyon:01 0100,:01 mutable:01 ocaml:01 read-only:01 mutable:01 ocaml:01 cheers:01 2009:98 wrote:01 caml-list:01 immutable:01 immutable:01 strings:01 strings:01 On Fri, 2009-04-03 at 12:56 +0100, Jon Harrop wrote: > I read that batteries included provides first-class rope-based strings and I > was just reading up on some horror stories about immutable strings on > StackOverflow. This made me wonder what people's thoughts are about mutable > vs immutable strings? Note that Batteries provides * regular OCaml strings * strings with capabilities (i.e. strings which, depending on their type, can be read-only/write-only/read-write) -- sometimes faster than regular strings, never slower * immutable Unicode ropes. I personally can't remember the last time I've needed mutable strings in OCaml. On the other hand, I can remember a handful of times where, to return a constant string, I had to make a function that would rebuild the string at every call. Which is both needlessly slow and awkward for what looks like a constant. Cheers, David