WIp prohibit calling of @configurables in default arguments of other functions
adresses issue #46 (closed)
This implements a rather fragile check in every call of a configurable, whether this happens in a function definition, in which case we throw an attribute error.
It is done by checking the call site of a @configurable function call and inspect the surrounding code. if it includes a \s*def\s*
statement, we throw the error.
This has some flaws:
False negative example:
def g(
f = f()): pass
False positive example:
def g(f=f): f()
i hope the second case never happens, and that the first case is rare enough that we do not need to put much more effort into that check.
It becomes significantly more complex if we have to check multiple LoCs.
Another idea is to explicitly allow calls configurables only after some environment variable is set, i.e. in your options file:
from mod import f,g
from tonic import allow_calls # <- insert good name here
allow_calls()
# now i can do whatever i want.
This is significantly easier to implement and safer, but its also verbose/explicit and needs to be done in every top level optsfile AFTER all configurable imports.