[R6RS] Re: Zapping SET-CAR! & SET-CDR!
Mon Oct 18 14:31:59 EDT 2004
From: Michael Sperber <sperber at informatik.uni-tuebingen.de>
Date: Mon, 18 Oct 2004 19:36:42 +0200
Manuel> I'm strongly against this proposal. In my opinion, mutable
Manuel> pairs is strong characteristic of Lisp. It enables efficient,
Manuel> and sometime simpler, implementation of tree manipulation.
But these could be done with 2-element vectors as well. If you're
concerned about conciseness, you could do
(define (kons x y) (vector x y))
(define (kar x) (vector-ref x 0))
(define (kdr x) (vector-ref x 1))
(define (set-kar! x v) (vector-set! x 0 v))
(define (set-kdr! x v) (vector-set! x 1 v))
And klist, kappend, kmemq, and so on (KDE Scheme!). I am sympathetic
to wanting immutable pairs, but I think it is too big change. Too many
programs would break.
Moreover, I would think that the efficiency benefits of having only
immutable pairs would outweight those you cite.
There are algorithms that operate much more efficiently on mutable
lists. Some programs would win and some would lose because of
either using slower algorithms on immutable lists or by the added
cost of converting back and forth between the two types.
More information about the R6RS