One possible way is to create a transaction mechanism (rollback / commit). This is taken from the Xach Naggum archive :
I am missing a transaction object where I can make a number of changes
to a system that are only visible to my multithreaded thread
and then drop them or transfer them all to
once. For example, downloading a file may be such a transcription. alarm
an error during boot can lead to an integer number of operations preceding it to drop it, and not leave the system in a partially altered state. It is not possible to do this on top of an existing system, but it requires considerable effort, so this is what Common System Lisp programmers must do.
You would miss the opportunity to cancel only a subset of declarations, for example (declare A) , (declare B) , (undeclare A) , but given your motivation, this would not be a problem, because you probably want to cancel all possible announcements made in test time.
You can provide a special form for individual "undeclare" declarations. I would call it retract , but in some cases it can be difficult to determine. Suppose you state that x is a string or a number, can you cancel the declaration that says x is a string? What about inline functions, etc.? The deal looks easier to implement, for example, a temporary environment.
coredump
source share