John Cowan wrote:
> Ray Dillinger scripsit:
>
>> There's a compelling case for a scheme-oid lisp with a
>> "strings as immutable values" interpretation where
>> characters are just strings that happen to be short.
>
> +1
>
>> It would be cleaner semantics than R6, but such
>> a large semantic change and breaks so much existing
>> code that I can't imagine that it's likely to be a
>> reasonable direction to go.
>
> Also +1, alas.
We already have mutable and immutable strings - since
string literals are immutable.
We could define a new set of string functions that
return immutable strings, and deprecate the old ones.
Or change the definition of functions like substring
to return immutable strings. I would guess that the
strings returned by substring, string-append, and
list->string are seldom modified in practice, so
we could define them to return immutable strings.
To create a mutable string, use make-string, or a
(new) function string-copy, which can conveniently be
used to create a mutable string from an immutable string.
Once could also define the character type as a subtype of
the immutable-string type. Thus for example:
(string-length #\A) ==> 1
(string-ref #\A 0) ==> #\A
Probably:
(equal? "A" #\A) ==> #t
(eq? #\A #\A) ==> #t
(eq? "A" #\A) ==> unspecified
--
--Per Bothner
[email protected] http://per.bothner.com/
_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss