Protected-bindings is a library for combining the ideas of lexical clean-up via
unwind-protect and dynamic clean-up via finalization.
The main benefit of using this library is saving you the typing of using
tg:finalize. In order to properly use
and finalization, you must establish this clean-up immediately after the bind in
order to mitigate the risk of a condition transferring control out of your code
and missing the clean-up. This means that you typically shouldn’t bind several
things and then use one
unwind-protect to clean them all up, even though this
is a natural inclination. We provide an interface that will immediately
institute the clean-up after the bind without the excessive syntactic overhead
of multiple nested
The interface is very simple. A single macro is defined,
with-protected-bindings*, which provides a
let* like interface with arbitrary
extra forms after the value of each binding that specifies how to clean up the
binding. This is typically taken as a lexical clean-up, setting up an
unwind-protect form. However, if the first form in the clean-up code in the
:finalize, the following result of the immediately following form is
taken to be a thunk that performs the clean up. All forms after that thunk are
again used in the unwind protect clean up.
I may someday implement a
with-protected-bindings for parallel bindings, the
let, for symmetry, but this really isn’t usually needed.
Only trivial-garbage. Any implementation that has finalization support should be supported.
Issues that are found are dealt with in short order, but…
This software is very lightly tested and should be considered relatively immature. If you use it in your project, or are just trying it out and find a glaring mistake, I would appreciate you dropping a complaint in the issues section or by email.