Sunday, 18 August 2013

How to watch out for the fact that NREVERSE may modify CARs instead

How to watch out for the fact that NREVERSE may modify CARs instead

http://www.aiai.ed.ac.uk/~jeff/lisp/cl-pitfalls states this as one of
Common Lisp pitfalls
Destructive functions that you think would modify CDRs might modify CARs
instead. (Eg, NREVERSE.)
I am not sure what precautions I am supposed to take. Usual precaution I
can take from the fact that NREVERSE may modify CDRs is to use NREVERSE
only when the list (the argument) does not share tail with any other lists
that my variables may refer to later (except for the variable I save the
return value to). What precaution I should take from the fact that
NREVERSE may modify CARs? How is this something to watch out for?

No comments:

Post a Comment