chickadee » srfi-189 » either-let*

(maybe-let* (claw ...) . body)syntax
(either-let* (claw ...) . body)syntax

The Maybe/Either equivalent of and-let* from SRFI 2. However, instead of testing whether a claw is true or false, it tests whether it is Just/Right or Nothing/Left. If a claw does not evaluate to a Maybe/Either, an condition of kind (exn type assertion) is raised. If a claw evaluates to a Just or Right that wraps zero values or more than one value, then a condition of kind (exn type payload) is raised.

A claw is either a bound identifier, or a list of length 1, in which case it is an expression, or a list of length 2, in which case it is a variable and an expression. In either case, the value of the claw is the value of the bound variable or expression. If the value of a claw is Nothing / a Left, the expression immediately returns that value. But if the value of a claw is a Just/Right, then the variable (if any) is bound to its unwrapped value; the scope of this binding is any remaining claws and the body.

If the values of all the claws are Just/Right, then the body is evaluated as if it were in a (let () ...), and its values are wrapped in a Just/Right and returned.