License: Public Domain , Load it with Quicklisp: (ql:quickload "with-shadowed-bindings")
Library type: Macro , Project complexity: Trivial

with-shadowed-bindings establishes a new lexical context
within which specified bindings are explicitly shadowed,
making it clear that they are not referenced within,
thereby reducing cognitive load.

with-shadowed-bindings » Dictionary

...2 » with-shadowed-bindings

Macro with-shadowed-bindings

bindings &body forms => results

Arguments and Values

  • bindings -- A list.
  • forms -- An implicit progn.
  • results -- The values of the forms.

Description

Establishes a new lexical context within which the named bindings cannot be directly accessed, executes forms as an implicit progn within that context and returns the results.

Each binding names a binding to shadow, of either of the following types:

  • A symbol names a variable or symbol-macro to shadow.
  • A list of 2 elements with function as the first element and a function name as second element names a function or macro to shadow.

Throws an with-shadowed-bindings:invalid-access error if an attempt is made to access any of the shadowed bindings within forms.

Currently, no attempt is made to detect if the named bindings to shadow are actually accessible in a parent environment.

Currently, there is no way to define new kinds of bindings that one could shadow.

For now, see the unit tests for examples.

...2 » invalid-access

Generic Function with-shadowed-bindings:kind

condition => kind

Description

Returns the appropriate slot value from a with-shadowed-bindings:invalid-access condition.

kind is one of :variable, :function or :macro.

Generic Function with-shadowed-bindings:name

condition => name

Description

Returns the appropriate slot value from a with-shadowed-bindings:invalid-access condition.

name is usually a symbol. In the case of a setf function, it would be (setf name).