Open cowlicker12 opened 1 year ago
Hi @cowlicker12, this is a bit on the architecture decision and a bit of a preference. In this case, the normal_summon()
is appending to a stack of function pointers which will later be resolved.
So in this case, we want _normal_summon()
to capture the variables player
and other values passed to normal_summon()
as part of callback. This is often called a closure and commonly used in functional programming-like architecture. Or very common in Javascript / NodeJS programming techniques where callbacks are required.
There could have been other ways to approach this implementation such as a class instance or an external function that returns a closure. However, this was the most succinct to write inlined, and no other function requires this _normal_summon
definition so a private function was used.
Hope that helps. Feel free to close if this makes sense.
This might be an advanced python technique that I'm not aware of, but why is there a private version of a function inside of the function? For example:
Inside of
normal_summon()
, we have_normal_summon()
. Why is this?