Version française
Home     About     Download     Resources     Contact us    
Browse thread
Not really a bug but...
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] Not really a bug but...
On Sat, 2007-06-16 at 12:10 +0200, Loup Vaillant wrote:
> 2007/6/16, Alain Frisch <Alain.Frisch@inria.fr>:
> > Jon Harrop wrote:
> > > Any chance of changing the semantics of string literals so they aren't static?
> > [...]
> > If it were done automatically, there would be a penalty for
> > the common case of immutable strings; to avoid it, you'd need to lift
> > constant literals out of abstractions, which is not very nice.
> 
> By the way, why Ocaml didn't take the Java path, i.e. making truly
> immutable strings, And provide mutable string buffers as well?

It didn't because it didn't .. :)

Strings are mutable because they can be, without impacting
the run time/garbage collector: Ocam's razor says use
one type when it will do the work of two.

It's unfortunate that in the abstract, Ocaml string are
entirely the worst possible multi-function data type as a result,
since they neither offer the advantages of immutability nor the
advantages of being variable length: mutable fixed length strings
are almost useless .. but not entirely: they're still useful as I/O
buffers.

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net