[bitc-dev] Problem: mutable literals
David Hopwood
david.nospam.hopwood at blueyonder.co.uk
Fri May 19 15:01:08 EDT 2006
Jonathan S. Shapiro wrote:
> HOWEVER: the partial evaluation of *immutable* content is actually
> important. When we see:
>
> (let ((v (vector (the int 1) 2 3))) ...)
>
> is the compiler obligated to allocate a new vector on each entry?
>
> It is tempting to imagine that no operator will reveal the partial
> evaluation, but consider:
>
> (define v-save:(mutable (vector int)) (vector 1))
>
> (define (f)
> (let* ((v (vector 1 2 3))
> (result (eq? v v-save)))
> (set! v-save v)
> result))
>
> If partial evaluation is permitted, the first invocation of F will
> return #f, but the second will return #t.
One possible viewpoint is to consider this to be a problem with 'eq?'.
If a language only has Henry Baker's 'egal?' operator:
Equal Rights for Functional Objects, or The More Things Change,
The More They Are the Same
<http://citeseer.ist.psu.edu/baker93equal.html>
then it cannot observe whether a reference to a deeply immutable
data structure is shared or not.
The difficulty then is that 'egal?' is not constant time, and sometimes
(not very often), you really want a constant-time reference equality
test.
--
David Hopwood <david.nospam.hopwood at blueyonder.co.uk>
More information about the bitc-dev
mailing list