Re: strings and char arrays (Re: #\a octothorpe syntax vs SRFI 10)
Aubrey Jaffer 02 Jan 2005 18:47 UTC
| Date: Sat, 01 Jan 2005 19:04:59 -1000 (HST)
| From: Shiro Kawai <xxxxxx@lava.net>
|
| From: Aubrey Jaffer <xxxxxx@alum.mit.edu>
| Subject: Re: #\a octothorpe syntax vs SRFI 10
| Date: Sat, 1 Jan 2005 23:34:06 -0500 (EST)
|
| > | > char (string) #nA:char
| > |
| > | Is that 8-bit chars or implemention-defined chars?
| >
| > Those are Scheme chars (implementation-defined). Multi-lingual
| > implementations might have several sizes seamlessly switched behind
| > the scenes depending on the characters written into them.
|
| The new draft (srfi-58-new.html) still says:
|
| "All implementations must support the character array type,
| the rank-1 character arrays being strings."
|
| As Bear pointed out in <Pine.LNX.4.58.0412301550550.3862@bolt.sonic.net>,
| a string may not be implemented as a simple array of characters.
| It is always possible to implement array operations on strings
| since they can be accessed by index. However, having distinct
| character array objects may be good in some implementations
| where strings have indexed access costs more than O(1).
If an implementation has character arrays distinct from strings, then
the SRFI-47 code should dispatch to handle strings. The SRFI-47
reference implementation does such dispatch for strings and vectors.
| Are you suggesting that a string _should_ be an array of
| characters, or did you just included it because of convenience?
I have changed it to say:
SRFI-47 Clarification
All implementations must support Scheme strings as rank 1
character arrays. This requirement mandates that Scheme strings be
valid arguments to array procedures; the stored representations
may be very different from other character arrays. Note that
Scheme strings may have indexed access times slower than character
arrays or other arrays. Note also that character arrays may have
slower access times than Scheme strings or other arrays.
| Whichever, it'd be nice that the design choice is noted in the
| Rationale section, and warn the readers that they can't count on
| O(1) indexed access for character arrays (if you keeps rank-1
| character array and string equivalence).
Isn't the best possible array indexed access time O(rank)?