[r6rs-discuss] set-car!

From: William D Clinger <will>
Date: Fri, 22 Jun 2007 16:22:00 -0400

Alan Watson wrote:
> The only way to provide these guarantees is to perform a whole-program
> analysis and look for either set-car! or set-cdr! (in the case of R5RS)
> or an import of mutable-pairs (in the case of R6RS). So, in essence,
> nothing has changed between R5RS and R6RS: pairs are still potentially
> mutable.

That is true, but the R6RS could be seen as facilitating
an improvement.

The mapping from library names/versions to actual code
is beyond the scope of the current draft R6RS, which is
why it is addressed only within the non-binding appendix.

(BTW, that also points out how silly it is for the R6RS
to waste space describing the semantics of versions, or
for us to act as though what the R6RS says about versions
were meaningful. The actual semantics of versions will
be implementation-dependent anyway, since conforming
implementations are allowed, when mapping library names
and versions to actual code, to use arbitrarily perverse
interpretations of the version constraints that appear
within an import clause [1].)

OTOH, we can expect at least some implementations will
behave reasonably, and will provide programmers with
some measure of control over the mapping from library
names to code.

In such implementations, programmers will be able to
substitute the following library for the one provided
by the implementation:

    (library (rnrs mutable-pairs (6))

      (export set-car! set-cdr!)
      (import (rnrs base (6)))

      (define error-message
        "The (rnrs mutable-pairs (6)) library is off-limits.")

      (assertion-violation #f error-message)

      (define (set-car! p x)
        (assert #f))

      (define (set-cdr! p x)
        (assert #f)))

This isn't foolproof, because someone might perform a
similar substitution for the (rnrs base (6)) library.

A similar effect could be obtained under the R5RS by
redefining set-car! and set-cdr!, which all conforming
implementations must allow, but that's more awkward in
the R5RS because there is no standard way to signal an
error. One small step for a language, one giant leap
in the complexity of its specification.

Will


[1] The situation with library names and versions is
just like the situation with respect to declarations
in the 5.91 draft: The declarations of that draft
were nothing more than a standardized syntax for
implementation-dependent semantics, just as the library
names and versions of the 5.94 draft are nothing more
than a standard syntax for implementation-dependent
semantics. There is genuine value in having standard
syntax for implementation-dependent hooks. I hope the
participants in this forum will see the value of having
it for library names, even if they didn't see the value
of it for declarations.
Received on Fri Jun 22 2007 - 16:22:00 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC