[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2005-02-10 (19:26) |
From: | Jon Harrop <jon@j...> |
Subject: | Re: [Caml-list] String to list to string |
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.