Egregoros

Signal feed

Timeline

Post

Remote status

Context

1

Replies

7
I don't get why having closures is such a good thing.
duplicating the function and variables is by definition not just "absolutely necessary" memory but idk jack shit about functional so who knows how they do it.
In general though, claiming that Python programs become more readable when you use closures than with global state seems a bit dubious to me. Maybe I'd like it in functional programming though.
my naive answer would be isn't that more about control flow than the variable being global or not?
Calling an object that encapsulates the state doesn't make it more understandable than just having a global edit_mode_toggle and toggling that within program flow...

>, there is no duplication, the function chain compiles into an imperative loop
this is more of a stack overflow/google stupid question I guess, but if the function is just made once and the language internally just passes a pointer to the variables it needs on execution, isn't that just a bit of syntactic sugar around doing that yourself? where's the closure part come in?
I got a bit less sleep so apologies if this is a dumb thing to ask
@WandererUber @HatkeshiatorTND the variable being global doesn't change control flow but does obscure it and make the code as written not describe it without knowing the entire system
although for python it does indeed not matter as it has no concept of const so data dependencies are already obscured, so something being global doesn't obscure it more than it being in a state object

variables are already pointers in assembly. and yes you can spin up for loops with nested conditions that are equivalent to a zip.map.filter.fold chain, but it will be far less concise and readable than the functions that describe the logical transformations