Arc Cross Reference

iflet

[macro] iflet var expr then rest ...

Evaluates expr. If it yields non-nil, binds the result to var and evaluates then. Othewise interpretes rest as in if.

(mac iflet (var expr then . rest)
  (w/uniq gv
    `(let ,gv ,expr
       (if ,gv (let ,var ,gv ,then) ,@rest))))

See also whenlet.

In the standard Scheme terms, it captures this common pattern (NB: if rest has multiple forms, the expansion will be a bit different because of Arc's if semantics).

(cond [expr => (lambda (var) then)]
       [else rest])

Categories:conditional,binding