Type-checking in Guile primitives distinguishes between mutable strings
and read only strings. Mutable strings answer
string? while read only strings may or may not. All kinds of
strings, whether or not they are mutable return #t to this:
This illustrates the difference between
(string? "a string") => #t (string? 'a-symbol") => #f (read-only-string? "a string") => #t (read-only-string? 'a-symbol") => #t
"Read-only" refers to how the string will be used, not how the string is permitted to be used. In particular, all strings are "read-only strings" even if they are mutable, because a function that only reads from a string can certainly operate on even a mutable string.
Symbols are an example of read-only strings. Many string functions,
string-append are happy to operate on symbols. Many
functions that expect a string argument, such as
accept a symbol as well.
Shared substrings, discussed in the previous chapter, also happen to be read-only strings.
Go to the first, previous, next, last section, table of contents.