Wrote a custom debugging tool in Lisp that allows you to set up any number of associative pairs of debug-mode/debug-value, either at compile time or run-time.
The neat part is anything established at compile time effectively becomes a more powerful version of #ifdef, such that if some piece of code tests for that debug-mode to be established and it *hasn't* been established, that code isn't even compiled.
In other words:
The code above will only be compiled and run if the debug mode "array-test" has been established. If it hasn't none of this is executed and there is no speed hit.
I can also check to see if a debug-mode is set to a certain value. So I might set "array-test" to "level-1" if I want to do minimal testing on arrays, and "array-test" to "level-2" if I want more advanced testing.
So I can conditionally compile debug code based on the value of a debug mode like so
so if array-test = level-2 *at compile time*, the code is compiled and added to the program. If it isn't equal to level-2, the code is not compiled or inserted into the program. Again, no speed hit.
Basically it's an advanced version of #ifdef that allows comparisons to variables and such.
The neat part is anything established at compile time effectively becomes a more powerful version of #ifdef, such that if some piece of code tests for that debug-mode to be established and it *hasn't* been established, that code isn't even compiled.
In other words:
(with-debug-mode-present-at-compile-time array-test //code goes here//)
The code above will only be compiled and run if the debug mode "array-test" has been established. If it hasn't none of this is executed and there is no speed hit.
I can also check to see if a debug-mode is set to a certain value. So I might set "array-test" to "level-1" if I want to do minimal testing on arrays, and "array-test" to "level-2" if I want more advanced testing.
So I can conditionally compile debug code based on the value of a debug mode like so
(with-debug-mode-equalp-at-compile-time (array-test level-2) //code here//)
so if array-test = level-2 *at compile time*, the code is compiled and added to the program. If it isn't equal to level-2, the code is not compiled or inserted into the program. Again, no speed hit.
Basically it's an advanced version of #ifdef that allows comparisons to variables and such.