Is there a way in Scala to detect whether a function
f is being called within the dynamic extent of function
I have a function
f which, when called, may destroy a particular data structure, unless it is called within the dynamic extent of
g. I can document this in the comment of
f but I’d like to enforce it if possible.
In Common Lisp I would bind a dynamic (thread-local) variable to
g, and assert the value of that variable is
I’m tempted to use DynamicVariable, and just emulate the CL idiom. But perhaps there’s a more Scala-think way?