From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id XAA22199 for caml-redistribution; Wed, 12 Jan 2000 23:15:27 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id XAA07210 for ; Wed, 12 Jan 2000 23:10:00 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id XAA08526; Wed, 12 Jan 2000 23:06:35 +0100 (MET) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id XAA21693; Wed, 12 Jan 2000 23:06:35 +0100 (MET) From: Pierre Weis Message-Id: <200001122206.XAA21693@pauillac.inria.fr> Subject: Re: Immutable arrays (modest Feature request) To: ohl@hep.tu-darmstadt.de Date: Wed, 12 Jan 2000 23:06:35 +0100 (MET) Cc: caml-list@inria.fr In-Reply-To: <200001121545.QAA25233@heplix4.ikp.physik.tu-darmstadt.de> from "Thorsten Ohl" at Jan 12, 0 04:45:42 pm X-Mailer: ELM [version 2.4 PL24 ME8] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: weis > I've always wondered why O'Caml has no notion of immutable arrays or > vectors. (Mutable) Arrays are often inconvenient because callers and > callees must negotiate who is doing the copying. A conservative > approach will do too many copies. > > Semantically, a vector of size n would be a record with > labels 0,...,n-1 and with O(1) access. One would initialize them from > a constant (e.g. let v = [{ 42; 137; 1789 }]), a list, an array, or a > function. Updates would be requested by [{ v with 2 = 2000 }] and most > of the Array and List library is useful for vectors. > > I admit that this is theoretically not very exciting (except for the > question when the `with' must copy and when not), but rather useful. > > Cheers, > -Thorsten > -- > Thorsten Ohl, Physics Department, TU Darmstadt -- ohl@hep.tu-darmstadt.de > http://heplix.ikp.physik.tu-darmstadt.de/~ohl/ [<=== PGP public key here] It existed in the past in Caml for strings (named ropes) and vectors (named segments). It has been removed since nobody used them ... I'm not sure it is worth the additional complexity ... Pierre Weis INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://cristal.inria.fr/~weis/