Alternatively, if you want to indiscriminately capture and restore all parameters, you could write:
(let ([saved-paramz (current-parameterization)])
(delay (call-with-parameterization saved-paramz
(λ ()
...code goes here...))))
I've also come to at least a soft version of this view. Two examples that particularly get to me:
- The way the
json
library uses(json-null)
means that even the result ofjsexpr?
depends on a relatively obscure piece of mutable state, which makes it difficult/expensive to check as a contract. Thetyped/json
library works around this with wrapper functions that supply#:json-null 'null
. - I once wrote some
#lang web-server
code that had a rather bad bug until Jay explained to me on the mailing list that:-
A continuation captures the values of parameters at the time it is
captured. So, if your parameterize is outside of the dispatcher that
calls the continuation, then the code inside the continuation will not
see the parameter change. That's a pretty important feature of
continuations. -
Web parameters would work the same way as normal parameters and not help you.
-
The stateless Web language guarantees that the parameters will have
values they had when the servlet was initialized. -
I think that you may want to use a thread-cell as the storage place.
-