From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id CA8F6BB83 for ; Mon, 29 May 2006 01:20:42 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k4SNKfpn030815 for ; Mon, 29 May 2006 01:20:42 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id BAA08661 for ; Mon, 29 May 2006 01:20:41 +0200 (MET DST) Received: from azsmga101.ch.intel.com (mga07.intel.com [143.182.124.22]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k4SNKdYq016358 for ; Mon, 29 May 2006 01:20:40 +0200 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 28 May 2006 16:20:38 -0700 Received: from orsmsx331.jf.intel.com (HELO orsmsx331.amr.corp.intel.com) ([192.168.65.56]) by azsmga001.ch.intel.com with ESMTP; 28 May 2006 16:20:38 -0700 X-IronPort-AV: i="4.05,182,1146466800"; d="scan'208"; a="42765252:sNHT16033682" Received: from orsmsx409.amr.corp.intel.com ([192.168.65.58]) by orsmsx331.amr.corp.intel.com with Microsoft SMTPSVC(6.0.3790.211); Sun, 28 May 2006 16:20:32 -0700 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: [Caml-list] Re: immutable strings (Re: Array 4 MB size limit) Date: Sun, 28 May 2006 16:20:30 -0700 Message-ID: <196F1D996F92CD46A542EA519DB8CE4703CCA9F0@orsmsx409> Thread-Topic: [Caml-list] Re: immutable strings (Re: Array 4 MB size limit) thread-index: AcaANXWbIX3Vuj9PTaSxNQrQZotXagCd4rVw From: "Harrison, John R" To: "Martin Jambon" , "Caml List" Cc: "Harrison, John R" X-OriginalArrivalTime: 28 May 2006 23:20:32.0183 (UTC) FILETIME=[50B80C70:01C682AD] X-Miltered: at concorde with ID 447A3049.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 447A3047.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; johnh:01 datatypes:01 caml-list:01 interfaces:01 immutable:01 immutable:01 unsafe:01 strings:01 strings:01 data:02 ichips:02 functional:02 functional:02 string:02 string:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 Hi Martin, | I disagree: has it ever happened to you to mutate a string by accident? The point is not that I will mutate a string by accident. I've never done it by accident or by design. The point is that I can't depend on code that I call, or code that calls mine, not to subsequently modify strings that are passed as arguments. So if I really need to reliably fix them I am forced into expensive copy operations. In practice, the obvious library calls are safe, so like Aleksey, I use the built-in strings for the sake of convenience and compatibility. But it's unsatisfactory intellectually. Some of us want to program in a primarily functional style, yet the implementation of one of the most basic and useful datatypes is not functional. | Yes, so how do you avoid copies without using the "unsafe" conversions all | over the place? With immutable strings, you'd never need to do conversions at the module interfaces. As with any other functional data structure, you only copy when you want to change part of it. John.