caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: brogoff <brogoff@speakeasy.net>
To: "Harrison, John R" <johnh@ichips.intel.com>
Cc: caml-list@yquem.inria.fr
Subject: RE: [Caml-list] String to list to string
Date: Thu, 10 Feb 2005 11:32:22 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.58.0502101102530.19029@shell3.speakeasy.net> (raw)
In-Reply-To: <012676D607FCF54E986746512C22CE7D02DF7754@orsmsx407>

On Thu, 10 Feb 2005, Harrison, John R wrote:
> | > Haskell treats strings as lists of chars by default.
> |
> | Just goes to show you that even really smart people can do some
> amazingly
> | dumb things.
>
> That's far too categorical; opinions differ on this subject.
> I'd be
> quite
> happy with strings as lists of characters, and I consider OCaml's
> mutable
> strings a far worse design error.

I disagree. Given strings as lists, or even something not as ridiculous, like
ropes (which Pierre Weis said existed in an older Caml) the programmer can
not write an efficient mutable string over it.  And, mutability aside, string
algorithms usually view strings as arrays, not lists. At least the other lazy
language gets this right. You would penalize almost all nontrivial string
manipulation programs if we fixed this "design error" with the approach you
find less odious.

IMO, the problem is that no one string (or array) type suffices for all or even
most purposes, and without some kind of overloading, having say five or six
different string types becomes notationally heavy.

So, while I'd love to have immutable strings, if there is going to be just one
privileged string type in OCaml, I think mutable strings are a reasonable
choice, not an error. Error is far too categorical.

> And yes, I use "implode" and "explode" all the time,

Have you no shame, to broadcast these perversions in a group which may have
young programmers? Really! ;-)

> because lists of
> characters are often simple and convenient to deal with in a functional
> style, and string manipulations are almost never performance-critical
> in the kind of code I write.

And you can (but shouldn't!) write those functions in your sleep in a few lines
of ML, over the existing mutable strings.

My preference for functional string processing is, as I said, substrings.
They are convenient, and encapsulate the index manipulations in the
data type. I'm almost certain you've seen them, what's your issue?

-- Brian


  parent reply	other threads:[~2005-02-10 19:32 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
2005-02-10 19:32 ` brogoff [this message]
  -- 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=Pine.LNX.4.58.0502101102530.19029@shell3.speakeasy.net \
    --to=brogoff@speakeasy.net \
    --cc=caml-list@yquem.inria.fr \
    --cc=johnh@ichips.intel.com \
    /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).