2 ms·
> cies said structs were ok, what's the difference in this regard? Small, appropriately scoped structs are ok. Passing a big "god struct" around to functions t
by lmm 9y ago
> cies said structs were ok, what's the difference in this regard?
Small, appropriately scoped structs are ok. Passing a big "god struct" around to functions that are only going to use a couple of fields is bad.
> 'Shared state' doesn't usually refer to explicitly passing a data structure into a function as an argument; it's operating on shared state only in the same way that any function which takes for example a string or a hash does.
Passing a mutable value into a function still counts, I think.
- cies 9y ago> Small, appropriately scoped structs are ok. Indeed. Structs are specific, self is "the whole shebang". And while (annoyingly) explicit in Python, it is common and OO-practice to pass self to all non-static members, thus defacto the self is mostly there. Writing member methods as static (or class methods, as called in Ruby land), is a great way to make code a bit more "functional". At some point you simply do not use self anymore and the class is merely a namespace with some unused features.