|
|
|
|
|
by Jtsummers
1372 days ago
|
|
If Python were fully call by reference then: def g(y):
y = 3
x = 10
g(x)
x # => ??
If it's 3 then it's pass by reference here, if it's 10 it's pass by reference. Which is it?Additionally, for something to be a closure it has to close over something (an environment). What does `f` or `g` close over? Note that they aren't changing any environment, they are "merely" functions, not closures. Python does have closures, but those aren't examples of them. And being able to assign a function to a variable does not make a closure, or do you think that C has closures because it has function pointers? |
|
If it's 3 then it's pass by reference here, if it's 10 it's pass by value. Which is it?
(Don't hit reply when you're rushing out the door.)