Open jinyangcruise opened 6 days ago
I just find out that unbind()
can not only discard the arguments passed to the call()
or callv()
, but also the arguments bound by the bind()
which is chained after unbind()
.
So the conclusion
get_bound_arguments_count ` and `get_bound_arguments` should not be influenced by unbind() calls.
is not correct because unbind()
calls can still "unbind" the arguments bound by a following bind()
call. One example is:
var callable = func(a = 1): printt(a)
callable.unbind(1).bind(9).call() # Output is 1, not 9.
So the unbind
doesn't remove previously bound arguments but will remove following bound arguments if there is a following bind
.
NOTE: this does not mean get_bound_arguments_count
and get_bound_arguments
are totally correct and thanks dalexeev for looking into it and made a fix.
Tested versions
System information
Windows 11, Vulkan API 1.3.280 - Forward+ - Using Vulkan Device #0: NVIDIA - NVIDIA GeForce RTX 3060 Ti
Issue description
The doc of
get_bound_arguments_count
says:So we can guess that
get_bound_arguments
also influenced by unbind() calls.They bahave just as what the doc says however not be consistent with the real bound arguments used by Callable at runtime. See the code:
The output is:
The output shows that the
unbind()
call only discard the arguments we passed to the callable and does NOT remove previously bound arguments. In the case above,9
is discard byunbind(1)
and1
,2
are still bound to the last two argumentsc
andd
. This is not consistent with the result ofc.get_bound_arguments()
which says there is only one argument bound and the value is1
however we all know that there are two arguments are bound (1
toc
and2
tod
).In other words, if
get_bound_arguments
returning[1]
is correct, then we are being told that1
is bound to the argumentd
which is absolutely wrong.From another perspective, isn't the purpose of this method to tell us the real bound arguments used by a Callable? If not, what else can we use to get such information?
So my opinion is
get_bound_arguments_count
andget_bound_arguments
should not be influenced by unbind() calls.--------------------------Update----------------------------:
The conclusion
is not correct because
unbind()
calls can still "unbind" the arguments bound by a followingbind()
call. One example isSo the
unbind
doesn't remove previously bound arguments but will remove following bound arguments.Steps to reproduce
Use the code as a script of a 2D node scene and run.
Minimal reproduction project (MRP)
NA