[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
subst-if-not and nsubst-if-not, programming folk-lore
Date: Mon, 7 Jul 86 10:30 EDT
From: Guy Steele <gls@Think.COM>
Date: Sun, 29 Jun 86 19:42 EDT
From: David C. Plummer <DCP@QUABBIN.SCRC.Symbolics.COM>
...
Now, when one tries subst-if-not, one gets a small surprise until one
thinks about it a bit:
(let* ((item-list '(numbers (1.0 2 5/3) symbols (foo bar)))
(new (subst-if-not '3.1415 #'numberp item-list)))
(values new item-list))
=> 3.1415
(NUMBERS (1.0 2 5/3) SYMBOLS (FOO BAR))
How about
(let* ((item-list '(numbers (1.0 2 5/3) symbols (foo bar)))
(new (subst-if-not '3.1415
#'(lambda (x) (or (numberp x) (listp x)))
item-list)))
(values new item-list))
?
Sure, we can all find the right solution once we see the pitfall. My
point is to document the pitfall so people are less surprised when it
happens to them.
[I tried to test this, but there appears to be a trivial bug in the
Symbolics 3600 release 6.1 implementation of SUBST-IF-NOT.]
[Recently fixed. Somebody should write a program to analyze mail coming
out of vendors to track what areas of the software system the vendors
are working on...]
What the person probably wanted is to replace the non-null atomic
leafs. I'm not sure what to think. One thing I'm thinking is that
(n)subst-if-not is too counter-intuitive to be worth having in the
language, even for completeness. At the very list, I think the
book/manual should carefully discuss this issue to people don't get
confused for years.
At the very LIST, you say?
So I did. A recent typo I made was "If you are trying to confuse me,
you are goind a good job."
--Guy
--