From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p8SNWKd5028179 for ; Thu, 29 Sep 2011 01:32:20 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjYBAPCtg07RVdivkGdsb2JhbABCp38IFAEBAQEJCQ0HFAQigVMBAQEBAgESAiwBOAEDAQsBBQULOyISAQUBHAYTIodWmxYKjimFCokpAgQGhwYEjB2HOI0LPYFIgic X-IronPort-AV: E=Sophos;i="4.68,458,1312149600"; d="scan'208";a="111051456" Received: from mail-qy0-f175.google.com ([209.85.216.175]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 29 Sep 2011 01:32:14 +0200 Received: by qyk10 with SMTP id 10so3383358qyk.6 for ; Wed, 28 Sep 2011 16:32:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=XFzGCTw20GA5+P+teL2mK2881TS7QKRZtbpTwNuvobc=; b=fnjESncuUgIabbvZHoswrngpkbBw8yKJH04W2qRcoZ7RishZjnQ1QEeoT5XxuRs6Em 3YQTTpcC55SR4XKLMpvHDava5Abgxpy/ke+1cW9u0HqCz7Vvw8Xlib6xJAHOMm6JHyES jvKjqBd1lXV6FtYYuxx6fzWHfTVqp5XcDlMqY= MIME-Version: 1.0 Received: by 10.224.215.200 with SMTP id hf8mr7704492qab.263.1317252733217; Wed, 28 Sep 2011 16:32:13 -0700 (PDT) Sender: philippe.wang.lists@gmail.com Received: by 10.224.45.197 with HTTP; Wed, 28 Sep 2011 16:32:13 -0700 (PDT) In-Reply-To: <91C06ED2-1A8C-4F05-AEA7-ECB93A229113@inria.fr> References: <4E820844.7050705@soton.ac.uk> <2F6B5C48-88B0-4717-87FD-BD044B3D36E4@inria.fr> <4E830AC3.6020405@soton.ac.uk> <91C06ED2-1A8C-4F05-AEA7-ECB93A229113@inria.fr> Date: Thu, 29 Sep 2011 01:32:13 +0200 X-Google-Sender-Auth: HGavGzJSUM1xbm6HhOHV_ZM2j2k Message-ID: From: Philippe Wang To: Damien Doligez Cc: OCaML Mailing List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p8SNWKd5028179 Subject: Re: [Caml-list] Weird GC behaviour On Wed, Sep 28, 2011 at 5:30 PM, Damien Doligez wrote: > You should say (Ftag (String.copy "Hello")) if you want a fresh mutable > string.  I wouldn't recommend appending "" or using Obj.dup (yuck!) > > I agree it was a mistake to make strings mutable, but we have to live > with it for the time being.  If you want to be perfectly safe, you can > wrap all string literals with String.copy in your program. If the world tended to be ideal at some point, I'd say it should be a compiler option, like # ocamlopt -unshared-litteral-strings (or -shared-literral-strings) Sometimes it's painful that strings are mutable, but otherwise, it would be painful too (maybe less often, I don't know). I believe that the worst is to have *both* mutable strings *and* the necessity to copy them every time mutability makes it weird. When I teach programming using OCaml, I really dislike having to explain that we have to live with this awful semantics (fortunately the language has stunning great qualities). Well, I guess this discussion has occurred thousands of times already. Sorry for that. Cheers, -- Philippe Wang    mail@philippewang.info