trucler

2023-10-21

Library for managing lexical environments.

Upstream URL

github.com/s-expressionists/Trucler

Author

Robert Strandh <robert.strandh@gmail.com>

License

FreeBSD, see file LICENSE.text
README
Trucler

This library defines a CLOS-based protocol to be used by Common Lisp compilers for environment query and update. In addition, library authors can use the trucler-native interface to inspect native environments. Trucler supports introspection for variables, functions, tags, blocks and optimization policies.

1Examples

1.1Introspection at Macroexpansion Time

The following macro can be used to ensure the presence of a local symbolmacro, and to see whether it has the expected expansion:
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defvar *client* (make-instance 'trucler-native:client)))

(defmacro assert-local-symbol-macro-description
    (name &key (expansion nil expansion-p) &environment env)
  (let ((description (trucler:describe-variable *client* env name)))
    (check-type description trucler:local-symbol-macro-description)
    (when expansion-p
      (assert (equal expansion (trucler:expansion description))))
    `(values)))

1.2Introspection at Runtime

Trucler can also be used to inspect the runtime environment - here with anexample of querying the state of the variable *print-array*.
(trucler:describe-variable
 (make-instance 'trucler-native:client)
 nil
 '*print-array*)
; => #<trucler-native-sbcl::global-special-variable-description {100A7E5A23}>

2Related Work

Trucler can be seen as a modern, extensible version of the protocoldescribed in section 8.5 of the second edition of Guy Steele's book [[https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node102.html#SECTION001250000000000000000][CommonLisp, the Language]].

Dependencies (1)

  • acclimation

Dependents (0)

    • GitHub
    • Quicklisp