I like the idea of `if-let` (which you can see in Clojure, and
probably other languages). It's like anaphoric `if` but better
because you can name the result of the conditional test. (Intentional
variable capture is always best when you are controlling the variable
names; not having a name forced upon you.)
I think this is the idea Alex had for `let?`; however it seems
`let?` doesn't work with pil64 pattern bindings (i.e. destructuring
binds) and `let?` doesn't seem to have the possibility of an else
clause (either that or my imagination and overall pil knowledge
suffers enough not to see such a possibility -- Alex will tell me :).
Anyway, please feel comment, criticize, etc. If you do, I will learn
something. Thanks! --Rick
(if-let X 13 (- X 1) 0) #-> 12
(if-let X 13 (- X 1)) #-> 12 # you can leave off the Else clause.
(if-let X '() (- X 1)) #-> NIL # b/c no Else clause and false condition.
(if-let X 0 (+ 42 X) -1) #-> 42 # because 0 is "truthy".
(if-let (X Y) (1 2) Y 42) #-> 2 # pattern binding for pil64.
(if-let (X Y) 1 Y 42) #-> NIL # because the pattern binding failed.
(if-let (X Y) '() Y "test failed") #-> "test failed"
(if-let (X Y) NIL Y "test failed") #-> "test failed"
# A definition
(de if-let "Args"
## Better than anaphoric `if` because you can name the test result
(let ((@Pattern "Test" @Then @Else) "Args"
@Test-Result (eval "Test"))
(let (@Pattern @Test-Result)
'(@Pattern @Test-Result @Then @Else)))))