Alexey Dejneka <adejneka@...> writes:
> 400: "aggressive constant folding"
> - (compile '(lambda () (the integer (/ 1 0))))
> + (compile nil '(lambda () (or t (the integer (/ 1 0)))))
> signals an error.
I've a fix for (CONSTANTP '(THE INTEGER (/ 1 0))) => ERROR. It
won't fix this, though, as the (CONSTANTP '(/ 1 0)) => T -- which
comes down to #'/ being FOLDABLE.
For SBCL itself I can fix this by replacing combinations of CONSTANTP
and CONSTANT-FORM-VALUE with a single CONSTANTP/VALUE => boolean,
value function, that would be to catch errors and return NIL, NIL for
apparently constant forms like (/ 1 0) and eg. T, 3 for (/ 6 2).
...that still leaves user code, though. The question is, is '
(CONSTANTP '(/ 1 0)) => T
acceptable or not? I'm really not sure, but it seems wrong to me. If
it is wrong, is #'/ really supposed to be FOLDABLE? Or does FOLDABLE
not mean what I think it means?
-- Nikodemus Schemer: "Buddha is small, clean, and serious."
Lispnik: "Buddha is big, has hairy armpits, and laughs."
Nikodemus Siivola <nikodemus@...> writes:
> ...that still leaves user code, though. The question is, is '
> (CONSTANTP '(/ 1 0)) => T
> acceptable or not? I'm really not sure, but it seems wrong to me. If
> it is wrong, is #'/ really supposed to be FOLDABLE? Or does FOLDABLE
> not mean what I think it means?
FOLDABLE, as it was used within the compiler, meant that if calling it
(with constant arguments) didn't result in an error, then the result
could be used to constant-fold.
(I just got a little bit sarcastic with Roger Corman over this very
issue on comp.lang.lisp -- the thread is available at
-- so I'm not exactly overjoyed that careful-call has been
subverted in the compiler.)