| Shiro Kawai 2007-11-28, 10:13 pm |
| Joo ChurlSoo<i...@initerm.com> wrote:
> I occasionly have a vague notion that if all strings were defined as vectors
> terminated by the null-character as all lists are defined as pairs that are
> terminated by the empty list, many string-manipulated procedures could be
> defined more efficiently without using the STRING-LENGHT procedure explicitly
> (or implicitly).
> How about this wanton thought?
You'd need a special object which can't be a valid character to mark
the end of
strings, or you won't be able to handle strings that contain NUL-
characters
in it.
Whether it can be efficient or not depends, though. I suspect your
idea only
solves a small part of the problem. For example, it may not be very
good at
substring sharing, and won't help to improve fast concatenation; both
are
very frequent operation on strings, I think.
I'd rather like to make a string an opaque object which I can treat it
as
if a list of characters (as in Haskell), relatively fast indexing
(O(1) is
ideal, but O(log n) is OK), and fast concatenation.
|