Re: Immutable arrays (modest Feature request)

From: Pierre Weis (Pierre.Weis@inria.fr)
Date: Wed Jan 12 2000 - 23:15:27 MET

  • Next message: T. Kurt Bond: "LablTk not in MS Windows O'Caml 2.99?"

    > 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/



    This archive was generated by hypermail 2b29 : Wed Jan 12 2000 - 23:17:30 MET