caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: John Prevost <j.prevost@gmail.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] String to list to string
Date: Thu, 10 Feb 2005 21:05:42 -0500	[thread overview]
Message-ID: <d849ad2a05021018052de2eede@mail.gmail.com> (raw)
In-Reply-To: <1108084921.16698.213.camel@pelican.wigram>

On Thu, 10 Feb 2005 17:32:18 -0800 (PST), skaller
<skaller@users.sourceforge.net> wrote:
> Throws out transparency/persistence and fails to
> allow any length changing operations, which are
> common for strings -- overwriting strings is rarely
> needed. The only use I can think of is as a buffer
> (and we have Buffer module for that, and it
> also allows variable length)

As much as I hate to agree with skaller, I do agree here.  :)  Having
the only kind of strings be mutable strings (like this, with each
point in the string being mutable, but not other attributes) is
painful.  I *do* think that having a natively supported type for these
"octet buffers" is handy, especially when doing IO.  But most of the
time, I want something else.

One way to think about why it's irritating for me is that by far the
*easiest* things to point to for "reasons the ML type system is really
helpful" are refs and options.  Because the default behavior is that
everything is immutable, but refs are simple and easy to use, we have
the option in ML to choose whether our datatype should be mutable or
not.  (Extend that somewhat to include Caml's mutable annotation,
which I think is acceptable.)  Likewise, by default every value must
be given, but options give us the ability to provide a kind of "null"
value.  (And if we wish to define our own datatype, we can distinguish
different types of null--N/A vs. unknown, for a basic example.)

But the way Caml strings are done forces us to deal with the fact that
every string is mutable--we don't have the option of making a string
that isn't.  If we want to, we can package things up to prevent
this--providing a way to box up a string into an immutable string
(make a copy, prevent mutation using the type system).  But then we
can't use the standard library without unboxing (making another copy)
to get a "normal" string value out.

This isn't the end of the world, of course.  But it is a wart that I
periodically meditate on.

John.


  reply	other threads:[~2005-02-11  2:05 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-10 18:35 Harrison, John R
2005-02-10 19:28 ` Jon Harrop
2005-02-11  1:22   ` skaller
2005-02-11  2:05     ` John Prevost [this message]
2005-02-10 19:32 ` brogoff
  -- strict thread matches above, loose matches on Subject: below --
2005-02-10 21:18 Harrison, John R
2005-02-10 19:51 Harrison, John R
2005-02-07  2:24 Fwd: Re: [Caml-list] The boon of static type checking Jon Harrop
2005-02-10  2:10 ` String to list to string Juancarlo Añez
2005-02-10  2:27   ` [Caml-list] " William D.Neumann
2005-02-10  3:24     ` Erik de Castro Lopo
2005-02-10  6:31       ` Radu Grigore
2005-02-10  6:52         ` Erik de Castro Lopo
2005-02-10  3:41   ` Jon Harrop
2005-02-15  1:16     ` Aaron Bohannon
2005-02-15 10:33       ` Richard Jones
2005-02-15 13:34         ` Eric C. Cooper
2005-02-10 10:09   ` Richard Jones
2005-02-10 19:19     ` Juancarlo Añez
     [not found]     ` <E1CzJqb-00031c-00@furbychan.cocan.org>
2005-02-10 19:41       ` Richard Jones
2005-02-10 17:58   ` brogoff

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=d849ad2a05021018052de2eede@mail.gmail.com \
    --to=j.prevost@gmail.com \
    --cc=caml-list@yquem.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).