| This seems like a wild exaggeration: "The behaviour of every function in a mutable, imperative environment is dependent upon the state of all of the other (variables|attributes|bindings|whatever) in your program at the time the function is invoked." You can write a function in an otherwise mutable and imperative environment like Python: pi = 3.15 # damn, typo for the value of pi!
pi = pi * 15 # mutate it, wrongly again def sum(a, b):
return a + b
print sum(7, 8) Please tell me how sum() depends on pi. The program correctly prints 15. |
Each function only depends on the arguments passed in, and variables outside of its scope which are referenced. However, the same is true of every function called inside the function, and the dependency is transitive, so the impact of changes to variables that aren't explicitly threaded through leaks outside to functions that never mention them. That's the problem. Hidden state.
It's also the kind of issue that usually looks incredibly contrived in small (say blog-post-sized) code samples, but isn't funny anymore when you have to deal with big lumps of spaghetti code. Global variables make reasoning about dataflow hard. Real problem, poor description.