miniblog.

← Back to all posts
15
I've just added `and` to my toy lisp compiler: https://github.com/Wilfred/proper-compiler-hat/commit/af5c77e30ecbf4884e71c1177a086337aa74d237 It's just a plain function, not a macro or special form. Is that so bad? I've seen confusing uses of `and` with truthiness e.g. `(and maybe-nil (compute-default))` and I'd rather avoid that.

5 Comments

@wilfredh Cool hat
@wilfredh It’s somewhat bad. I prefer the name andf for the eager version of and. Both have their uses. Sometimes you need and, sometimes you need andf (to implement list masks, just map andf), and sometimes either works fine. As an example of the latter, (and (even? foo) (big? foo)) returns the same val as the andf equivalent but is cheaper if big? is expensive. However, I definitively rely on the laziness of and often. As, using it as control flow with implicit branching.
@wilfredh To me, coming from shell where foo && bar && baz && quux || frotz && xyzzy is a very good and useful construct, I expect the same out of the form version of and and or.
@wilfredh (or (expensive-option1) (expensive-option2) (expensive-option3))
@wilfredh I thought Lisp 'and' would be defined on a list of arguments, and not just two.