Egregoros

Signal feed

Timeline

Post

Remote status

Context

6
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.

Replies

1
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