cyclone/docs/api/srfi/2.md
2016-09-29 17:57:48 -04:00

23 lines
1.2 KiB
Markdown

# SRFI 2 - `and-let*`
The `(srfi 2)` library provides the `and-let*` macro, an `and` with local bindings.
Like an ordinary `and`, an `and-let*` special form evaluates its arguments -- expressions -- one after another in order, till the first one that yields `#f`. Unlike `and`, however, a non-#f result of one expression can be bound to a fresh variable and used in the subsequent expressions. `and-let*` is a cross-breed between `let*` and `and`.
See the [SRFI document](http://srfi.schemers.org/srfi-2/srfi-2.html) for more information.
- [`and-let*`](#and-let)
#and-let*
(and-let* (claws) body
claws ::= '() | (cons claw claws)
claw ::= (variable expression) | (expression) |
bound-variable
- The `claws` are evaluated in the strict left-to-right order
- For each `claw`, the `expression` part is evaluated first (or `bound-variable` is looked up)
- If the result is #f, `and-let*` immediately returns #f
- Otherwise, if the `claw` is of the form `(variable expression)` the `expression`'s value is bound to a freshly made `variable`
- The `variable` is available for the rest of the `claws` , and the `body`
- As usual, all `variable`s must be unique (like in `let*`)