Best afterFunctions: package an idea you can call
Parameters: order matters
When you call a function, the arguments fill its parameters by position, left to right. Get the order wrong and the function computes something else entirely — here, a negative amount of money 'left'. Watch the call stack bind the parameters.
We have a budget of 100 and have spent 30. Work out how much is left (we want 70).
Arguments in the wrong order execution-derived · CPython
3 variables
state after line 1 runs· pass 1 of 2
| variable | value |
|---|---|
remaining | <function remaining>coerced |
step 1 / 5
Click a line, drag the slider, or use the ← → keys.
What you are looking at
Watch the function's frame open: which parameter gets which value?
- Buggy —
remaining(30, 100)bindsbudget = 30andspent = 100by position, so it returns30 - 100 = -70. The arguments went in backwards. - Procedural —
remaining(budget=100, spent=30)names each argument, so they land on the right parameters regardless of order, andleftis the70we wanted.
Every state you see came from running the program under CPython's tracer at build time — see how GlassBox stays honest.