Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Macro let? with :when and :else expressions in the bindings.
Clojure
tree: 4bd4f978be

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src
.gitignore
README.markdown
project.clj

README.markdown

The let? macro expands into a let, except where a binding is followed by :when pred or :else else or both, in either order.

For a :when, the pred is evaluated after the associated binding is evaluated and must be truthy to continue evaluating the rest of the bindings and the body. If the pred is falsey, the else is the value of the let?, if present, or nil if not.

For an :else without a :when, if the associated binding is falsey, else is the value of the let?.

E.g.

(let?
  [foo (f1) :when (w) :else (e)
   bar (f2)]
  (b1)
  (b2))

expands into

(let [foo (f1)]
  (if (w)
    (let [bar (f2)]
      (b1)
      (b2))
    (e)))

and

(let?
  [foo (f1) :else (e)
   bar (f2)]
  (b1)
  (b2))

expands into

(let [foo (f1)]
  (if foo
    (let [bar (f2)]
      (b1)
      (b2))
    (e)))

The jar is available at https://clojars.org/egamble/let-else.

Something went wrong with that request. Please try again.