3 ms·
> Why do closures and objects arise in such a natural fashion My reasoning is we need a partitioned stateful function which is impossible to achieve and the al
by fendy3002 5y ago
> Why do closures and objects arise in such a natural fashion
My reasoning is we need a partitioned stateful function which is impossible to achieve and the alternative are worse:
- partition global state with your own object id
- passing all state as arguments
- isaacimagine 5y agoOther ways to manage state as well: - Managing state through a monad or effect system - Managing state through coroutines / continuations - Managing state through dynamic scoping (poor man's effect system) - Associating implicitly mutating functions with types without having full objects (Rust) Some of these are pretty powerful, especially effects and continuations. I think the reason we don't see more of them is because we haven't figured out a wholly ergonomic way to fit them into a language yet.