English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Array 4 MB size limit
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-05-20 (21:29)
From: Oliver Bandel <oliver@f...>
Subject: Re: immutable strings II ([Caml-list] Array 4 MB size limit)
On Sat, May 20, 2006 at 11:32:15AM -0700, brogoff wrote:
> On Fri, 19 May 2006, Brian Hurt wrote:
> > On Fri, 19 May 2006, Jon Harrop wrote:
> >
> > > Agreed. Should OCaml's successor have extensible arrays with 64-bit lengths
> > > and strings as char arrays?
> Strings are random access character collections, so under the hood they might
> be arrays, but I think mutable strings as the default string are a mistake.
> One can imagine other representations for strings, like ropes. I'd like a
> language to allow many different underlying string representations.

I think it would break too much code when changing the string behaviour now.

There should be a keyword "immutable" to make strings immutable.
Your idea would be to make it like records immutable as default
and then the "mutable" word must be used for mutable strings.

This would also work, but then, as mentioned above, this would berak
a lot of aleady existing code.

A compiler switch, that per default uses mutable strings,
so as to provide backwards compatibility, but can be changed
to immutable strings as default.
This default string representation then could be changed with indivdual
used keywords "mutable" and "immutable".

I don't know how much development effort this would be, but it would be a  fine thing.

\ default   ||   mutable strings   || immutable  strings    ||
 \-------+  ||   as default        || as default            ||
  keyword \ || (compiler switch)   || (compiler switch)     ||
    ./.     ||  all strings are    || all strings are       ||
            ||  mutable            || immutable             ||
  mutable   || all strings are     || all strings that      ||
            || mutable             || are not declared as   ||
            ||                     || mutable are immutable ||
 immutable  || all strings that    || all strings are       ||
            || are not declared as || immutable             ||
            || immutable are       ||                       ||
            || mutable             ||                       ||

In short words: The compiler flag would give the default string representation
in use, and the keywords "mutable" and "immutable" used for individual strings
would overwrite that default individally.
And as default for the compiler - for backward compatibility reasons -
would then be used the mutable string representation.