[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: immutable structures



Andy Freeman writes:

    Immutable cons structures bother me.
    Every other immutable structure in Scheme has a distinct reader
    syntax.

I think the idea is that QUOTE would mark structures as immutable.

    ...Would someone please enlighten
    me and justify immutable quoted structures without resorting to
    "[some] formal system is cleaner without distinguishing them" as the
    best reason?

There may be some formal systems that are made cleaner by making quoted
structures immutable, but the denotational semantics certainly becomes
more complex.

I think immutable pairs are motivated by the fact that in many systems
side effects to quoted list structure alter the source code, particularly
when the code is interpreted rather than compiled.  This can make it hard
to debug, so the implementors want to discourage such side effects by
calling them "errors".

If, on the other hand, side effects to quoted structure don't alter the
source code, then people get even more confused, as when a procedure
whose source code is

    (lambda (flag) (let ((x '(a))) (if flag (car x) (whiznagle x))))

returns 97 when passed a true argument.

Peace, Will