[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: strings and char arrays (Re: #\a octothorpe syntax vs SRFI 10)

This page is part of the web mail archives of SRFI 58 from before July 7th, 2015. The new archives for SRFI 58 contain all messages, not just those from before July 7th, 2015.



 | Date: Sat, 01 Jan 2005 19:04:59 -1000 (HST)
 | From: Shiro Kawai <shiro@xxxxxxxx>
 | 
 | From: Aubrey Jaffer <agj@xxxxxxxxxxxx>
 | 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@xxxxxxxxxxxxxx>,
 | 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)?