[plt-scheme] caution about use of 'pair?' in programs with mutable pairs?

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Mon Jan 14 19:13:50 EST 2008

On Jan 14, 2008, at 3:06 PM, John Clements wrote:

> I feel lucky not to have been bitten by this, but I can see some  
> potentially very painful bugs possible in a switchover from v3 code  
> to v4 code; in particular, code that uses 'pair?' to distinguish  
> empty from nonempty lists could misclassify mpairs as nulls,  
> leading to some very unpleasant "non-fail-fast" errors.  Instead,  
> it would seem to be wiser here to use (not (null? ...)) rather than  
> (pair? ...)

I don't understand your remark. When you know pair? of some value v,  
you can use car/cdr. If you know (not (null? v)), what do you really  

-- Matthias

Posted on the users mailing list.