[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Comments on the draft standard
A correct analogous program would be
(define mystring (string-copy "abc"))
(string-set! mystring 0 #\f)
I really don't care for this. It makes strings substantively
different from vectors, when conceptually they ought not be. Further,
why is it that strings are reasonable things to put into immutable
space and lists, lambdas, etc. are not?
There is no difference between strings, vectors, and lists at this
level. Your example used strings, so I just rewrote it to be correct.
Vector and list literals can be immutable as well and the same would
apply to them. As far as lambdas, they are not objects in the
language. Procedures are immutable in the standard since no
operations that destructure/mutate them are provided. Lists
representing lambda expressions and which evaluate to procedures are
just lists, so anything applying to lists applies to them as well.
I'm not defending immutable structures, I'm just interpreting the
report and the understanding of the authors at this point. Besides
the obvious implementation desire to put such literals in "immutable
space", there are other reasons, the main of which is that the static
meaning of programs becomes harder to determine if literals are
After seeing Jinx's response, [I still am not sure he was serious...]
it seems all the more important that section 3.5 make it explicitly
clear that an object is only a candidate for immutable storage if the
implementation can prove that it cannot be mutated by the program.
I was dead serious.
What you suggest would prevent most literals from becoming immutable
since they are externally visible or returned to the "outside world"
inside of lists or other structures which can be destructured outside.
Note that personally I don't really care what the report says about
mutating literals. I consider doing it bad style, but I don't like to
legislate style. Maybe one of the proponents of immutable literals
can better answer your objections.