Closed samdphillips closed 2 years ago
If <test>
returns a non-boolean value then
(if <test> #t #f)
means something different than
<test>
From @jackfirth:
I think having a syntax class that matches common expressions known to produce booleans only would be the way to go
A couple of other rules:
(if a a/#t b) => (or a b)
(if a b #f) => (and a b)
More ideas in this SO thread.
As I re-read this today, I thought a good coarse check would be to see if the test was a procedure call and if the procedure name ended with a ?
. And of course, @jackfirth added precisely that :)
Instead of
use
<test>
.Similarly if the branches are swapped suggest
(not <test>)
.