caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Philippe Wang <mail@philippewang.info>
To: Damien Doligez <damien.doligez@inria.fr>
Cc: OCaML Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Weird GC behaviour
Date: Thu, 29 Sep 2011 01:32:13 +0200	[thread overview]
Message-ID: <CAAFfW_rWiDLXJjNkXLo=8T_kPtBtvERUWL61CmDBMEB6T=ffzA@mail.gmail.com> (raw)
In-Reply-To: <91C06ED2-1A8C-4F05-AEA7-ECB93A229113@inria.fr>

On Wed, Sep 28, 2011 at 5:30 PM, Damien Doligez <damien.doligez@inria.fr> 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


      reply	other threads:[~2011-09-28 23:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-27 17:30 Thomas Fischbacher
2011-09-28 11:19 ` Damien Doligez
2011-09-28 11:53   ` Thomas Fischbacher
2011-09-28 12:12     ` Gabriel Scherer
2011-09-28 13:07     ` John Carr
2011-09-28 15:30     ` Damien Doligez
2011-09-28 23:32       ` Philippe Wang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAAFfW_rWiDLXJjNkXLo=8T_kPtBtvERUWL61CmDBMEB6T=ffzA@mail.gmail.com' \
    --to=mail@philippewang.info \
    --cc=caml-list@inria.fr \
    --cc=damien.doligez@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).