3 ms·
> To me this just sounds like a discipline issue rather than a semantic one. Using an explicit parameter obviates the need for discipline since you can mechani
by maleldil 2y ago
> To me this just sounds like a discipline issue rather than a semantic one.
Using an explicit parameter obviates the need for discipline since you can mechanically trace where the value was set. In contrast, global values can lead to action at a distance via implicit value changes.
For example, if you have two separate functions in the same thread, one can implicitly change a value used by the other if it's thread-local, but you can't do that if the value is passed via a parameter.
- caspper69 2y agoI'm sorry I just think we're going in circles. A few posts up I clearly said use encapsulation and then mutate state via known methods. These would be just as traceable in your IDE/debugger. Further, I have also repeatedly mentioned both module-level and thread-level "globals". And I understand how concurrency works. Take care.
- Tainnor 2y ago> These would be just as traceable in your IDE/debugger. A debugger can trace a single execution of your program at runtime. It can't statically verify properties of your program. If you pass state to your functions explicitly instead of looking it up implicitly, even in dynamically typed languages there are linters that can tell you that you've forgot to set some state (and in statically typed languages, it wouldn't even compile).