All Manuals > LispWorks User Guide and Reference Manual > 40 The LISPWORKS Package

NextPrevUpTopContentsIndex

when-let

Macro
Summary

Executes a body of code if a form evaluates to non-nil, propagating the result of the form through the body of code.

Package

lispworks

Signature

when-let (var form) &body body => result

Arguments

var

A variable whose value is used in the evaluation of body.

form

A form, which must evaluate to non-nil.

body

A body of code to be evaluated conditionally on the result of form.

Values

result

The result of evaluating body using the value var.

Description

This macro executes the body of code if the form evaluates to a non-nil result. Within the body, the variable var is bound to the result of the form.

Example

The form

(when-let (position (search string1 string2))
   (print position))

macroexpands to

(let ((position (search string1 string2)))
   (when position
      (print position)))
See also

when-let*


LispWorks User Guide and Reference Manual - 20 Sep 2017

NextPrevUpTopContentsIndex