[r6rs-discuss] set-car!

From: Alan Watson <alan>
Date: Fri, 22 Jun 2007 13:30:41 -0500

John Cowan wrote:
> If it is
> known (by examining the transitive closure of all imports in a program)
> that set-car! and set-cdr! are not imported, then the implementation
> can use an alternative run-time in which pairs are immutable.

Well, you could get the same effect by scanning the whole program for
set-car!, set-cdr!, and eval, but scanning for imports is much more
convenient.

On the other hand, set-car! and set-cdr! seem to be different fish. If a
program doesn't use either, the implementation can use immutable pairs
generally and use optimized versions of map and friends. If a program
only uses set-car! but does not use set-cdr!, the implementation can no
longer use immutable pairs (without further analysis on a case by case
basis), but can use the same optimized versions of map and friends
(although possibly not assp).

So why not separate the mutable pairs library into a mutable cars
library and a mutable cdrs library?

I note that string-set! is shunted off into a library, presumably for
similar reasons. (Implementation techniques for strings were discussed
widely here and in the SRFI mailing list, and mutation is a problem.)

However, vector-set! is part of the base library. Are there no
"interesting implementation strategies" for immutable vectors, are they
thought to be not as worth optimizing as pairs, or are they being left
as the default mutable data structure so we don't have to mess around
storing values in closures?

Regards,

Alan
Received on Fri Jun 22 2007 - 14:30:41 UTC

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