[r6rs-discuss] set-car!

From: Alan Watson <alan>
Date: Fri, 22 Jun 2007 14:45:25 -0500

Carl Eastlund wrote:
> Having a guarantee of purity makes the pure functional style more
> usable for programmers.

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.

Now, such whole-program analyses are relatively simply is you are (a)
the implementation, (b) a program-to-program converter, or (c) the
person responsible for all of the code you are using.

However, if you are the author of a library, you cannot guarantee that a
user of that library will not mutate pairs. R6RS does not itself provide
any means to determine at compile-time or run-time whether pairs are
mutable. The best you can do is document this. Again, in essence,
nothing has changed between R5RS and R6RS.

As far as I can see, sticking mutable pairs in their library is about
making the whole-program analysis a little easier and about discouraging
mutation of pairs.

If you really want a usable and enforceable guarantee, perhaps you
should ask for a means to abort translation if pairs are potentially
mutable. (That would seem to be in keeping with other mechanisms in R6RS
that provoke compile-time rather than run-time errors.)

Regards,

Alan
Received on Fri Jun 22 2007 - 15:45:25 UTC

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