[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.

On Sat, 1 Jan 2005, Shiro Kawai wrote:

>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).

It's more than that, actually: string operations such as length-
changing mutation may be horribly inefficient on strings-implemented-
as-arrays, and array operations such as indexed-reference may be
suboptimal on strings.  Presenting strings that look like arrays
invites people to implement string operations in terms of array
operations, which could result in "worst of both worlds" performance.