One case I didn't discuss before is that of mutability contagion. R7RS-small backward compat requires that if all arguments are mutable, the result is mutable; by the same token, if all arguments are immutable, the result is naturally immutable. But if a procedure is passed both mutable and an immutable arguments of the same type, what should be returned?
- an immutable object (immutable contagion)
- a mutable object (mutable contagion)
- decided case-by-case for each procedure and/or each type
Programmer-written code will be decided by the programmer, so we need to decide only for the standard library. SRFI 135 chose uniform immutable contagion of strings without R7RS-small backward compatibility. SRFI 135x provides for uniform immutable contagion. The relevant procedures are string-replace, string-append, string-concatenate, string-concatenate-reverse, string-join, string-map, string-map-index. The SRFI 1 counterparts would be append, concatenate, zip, map, append-map, map-in-order, filter-map, and the lset-* procedures; the SRFI 133 counterparts would be vector-append, vector-concatenate, vector-append-subvectors, vector-map.
One case I didn't discuss before is that of mutability contagion. R7RS-small backward compat requires that if all arguments are mutable, the result is mutable; by the same token, if all arguments are immutable, the result is naturally immutable. But if a procedure is passed both mutable and an immutable arguments of the same type, what should be returned?
* an immutable object (immutable contagion)
* a mutable object (mutable contagion)
* decided case-by-case for each procedure and/or each type
Programmer-written code will be decided by the programmer, so we need to decide only for the standard library. SRFI 135 chose uniform immutable contagion of strings without R7RS-small backward compatibility. [SRFI 135x](https://htmlpreview.github.io/?https://raw.githubusercontent.com/johnwcowan/r7rs-work/master/srfi-135x.html) provides for uniform immutable contagion. The relevant procedures are `string-replace`, `string-append`, `string-concatenate`, `string-concatenate-reverse`, `string-join`, `string-map`, `string-map-index`. The SRFI 1 counterparts would be `append`, `concatenate`, `zip`, `map`, `append-map`, `map-in-order`, `filter-map`, and the `lset-*` procedures; the SRFI 133 counterparts would be `vector-append`, `vector-concatenate`, `vector-append-subvectors`, `vector-map`.