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
Unexpected behaviour of strings initialized with quotes
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-11-23 (20:56)
From: Martin Jambon <martin_jambon@e...>
Subject: Re: [Caml-list] Unexpected behaviour of strings initialized with quotes
On Wed, 23 Nov 2005, Arthur Chargueraud wrote:

> I am surprized by a difference of behaviour between the strings
> "bbbb" and (String.make 4 'b').


> This is not a real problem, since it is not usual to modify
> strings initialized with quotes, but I am just wandering
> about the reason of such a behaviour...

It's actually easier to write String.copy "abc" instead of "abc"
let f =
   let constant = "abc"
   fun x ->
      do_something_with constant

instead of:
let f x =
   do_something_with "abc"

which happens all the time.

Martin Jambon, PhD

Store and share your bioinformatics tips at http://wikiomics.org