Counterintuitive behaviour of bind
To me, bind
means 'override everything in this scope'. I'd expect this example to print 2
.
@configurable
def func(param=1):
return param
with func.bind(param=2):
with func.bind(param=3):
print(func())
Today's behaviour is that the most deeply nested bind
wins, so this actually prints 3
. This is at odds with how bind
overrides parameters used at the call site (which it does correctly IMO):
@configurable
def func(param=1):
return param
with func.bind(param=2):
print(func(param=3))
This does print 2
; we test that bind
works like this.
TL;DR: bind
currently overrides bind
calls that are higher in the call stack; we should change it so that higher bind
calls win, addressing this TODO.