Ludovic Courtes writes:
"Bill Schottstaedt" writes:

according to r5rs.html, these should signal an error, I believe:

guile> (string-set! (symbol->string 'immutable)
             0
             #\?)
guile> (define (g) "***")
guile> (string-set! (g) 0 #\?)
guile> (g)
"?**"

Not in R5RS. [1] But R6RS requires reporting. [2]

The attached patches against 1.8.x fix this.

Neil: OK to apply?

No, (read) should return mutable string.

"literal constants and the strings returned by symbol->string are immutable objects, while all objects created by the other procedures listed in this report are mutable." [3]

So scm_read_string() should behave differently when reads program and data.

-------
#;> (string-set! (read) 2 #\X)
"12345"

Backtrace:
In current input:
   1: 0* [string-set! "12345" 2 #\X]

<unnamed port>:1:1: In procedure string-set! in expression (string-set! (read) 2 ...):
<unnamed port>:1:1: string is read-only: "12345"
ABORT: (misc-error)
-------

szgyg

[1] http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-4.html#%_sec_1.3.2
[2]
http://www.r6rs.org/final/html/r6rs/r6rs-Z-H-8.html#node_idx_248
[3] http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-6.html#%_idx_76


Reply via email to