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

From: John Clements (clements at brinckerhoff.org)
Date: Mon Jan 14 15:06:05 EST 2008

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? ...).


John Clements

Posted on the users mailing list.