[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug & co



Manuel Giraud:
> 
> I think the function `reverse!' in MzScheme 103 is buggy. The behavior
> is the following :
> 
> > (define l '(a b c d))
> > (reverse! l)
> (d c b a)
> > l
> (a)
> ^^^  I think that '(d c b a) can be expected here, no?

?? Where have you been?
This IS PERFECTLY CORRECT. Draw the structure corresponding to '(a b c d),
four boxes. Draw a reference from l to it.
It points to the cell whose CAR contains 'a.

After the reversal the CDR of this cell becomes ().

Don't mix-up data and variables which point to them. Data may get reconstructed,
and then the references are invalidated.

Jerzy Karczmarczuk
Caen, France