caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jon Harrop <jon@jdh30.plus.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] String to list to string
Date: Thu, 10 Feb 2005 19:28:26 +0000	[thread overview]
Message-ID: <200502101928.26511.jon@jdh30.plus.com> (raw)
In-Reply-To: <012676D607FCF54E986746512C22CE7D02DF7754@orsmsx407>

On Thursday 10 February 2005 18:35, Harrison, John R wrote:
> ...I consider OCaml's mutable strings a far worse design error.

That's interesting. Why?

I appreciate ocaml allowing me to write efficient code for all sorts of things 
when I need to. I would be very miffed if the language enforced an 
inefficient style upon me. If ocaml used char lists then you have vastly 
different complexities for a variety of important operations. Which of these 
operations is most important is subjective, of course. If ocaml used an 
immutable char array then you would need quite a bit more in the compilers to 
get decent performance. If ocaml used a balanced binary tree then the pattern 
matcher would need to know about this kind of data structure and the 
asymptotic complexity of pattern matching would go from O(1) to O(ln n) for 
some leaf patterns.

Having said that, I have been bitten by some oddities (e.g. statically 
allocated string constants) but this seems like a small price to pay for the 
expressiveness of an impure functional language, IMHO.

I suppose you could have "abcd" patterns over the type "char list" instead of 
"string" whilst keeping the string type. Do many programs/functions use both 
string patterns and the mutability of the string type?

Of course, the usefulness of the current string type would be much more 
clear-cut in the presence of Richard Jones' style "abcd".. | .."dcba" 
prefix/suffix patterns as the latter can't be done on lists in O(m) (where 
"n" is the number of chars in the matched string and "m" is the number of 
chars in the string appearing in the pattern).

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.


  reply	other threads:[~2005-02-10 19:26 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 [this message]
2005-02-11  1:22   ` skaller
2005-02-11  2:05     ` John Prevost
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=200502101928.26511.jon@jdh30.plus.com \
    --to=jon@jdh30.plus.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).