3 ms·
In [0] the author uses dynamic scope (variables with dynamic scope are called special variable in common lisp) to help design a test system in common lisp. Quo
by curious1212 8y ago
In [0] the author uses dynamic scope (variables with dynamic scope are called special variable in common lisp) to help design a test system in common lisp.
Quoting the author: This is exactly the kind of problem dynamic variables were designed to solve.
Imagine that one of the test cases failed and you need to track down the problem. If you create a dynamic variable that each test function binds to the name of the function before calling check, then report-result can use it without check having to know anything about it.
I think that the main idea is that dynamic gives access to variables and functions defined in an upper level, something like creating classes and subclasses dynamically and they only live during a function evaluation.
[0] http://www.gigamonkeys.com/book/practical-building-a-unit-test-framework.html http://www.gigamonkeys.com/book/practical-building-a-unit-te...