| |
| Posted by Paulo Pinto in reply to forkit | PermalinkReply |
|
Paulo Pinto
Posted in reply to forkit
| On Saturday, 11 June 2022 at 01:14:16 UTC, forkit wrote:
> On Saturday, 11 June 2022 at 01:00:44 UTC, H. S. Teoh wrote:
>>
>> ..
>> You know how ridiculous that sounds, right? -- when you rephrase that in terms of a different unit of encapsulation. "I want to protect my function's per-object state from mutation by other functions in the class. My function will decide when to mutate, and when not to mutate. My class should not force mutation on me." Or, "I want to protect my local variables from mutation by other blocks in the function. My block will decide when to mutate, and when not to mutate. My function body shold not force mutation on me."
>>
>> One can argue that functions in a class ought to work together on that class's data; one could argue the same for functions (and other code) in a module. Or blocks in a function. It's essentially the same argument at the core; the only difference is the unit of encapsulation.
>
> Any argument taken to the extreme, will certainly sound ridiculour - as you've demonstrated.
>
>
>>
>> As I said, opinions differ on this. You say the class ought to be unit of encapsulation, Walter says it should be the module. Maybe next week I should write a DIP arguing for the block to be the unit of encapsulation instead. Each side of the argument has its merits and demerits; the choice is essentially arbitrary, based on what the language designer deems more important or not, in balancing the tradeoffs in the language.
>>
>> There are bigger fish to fry in the pond of programming language design.
>>
>>
>> T
>
> In OOP, opinions do not differ on the level of encapsulation. It is the class.
>
> I'm happy to be corrected here, if I'm wrong.
>
> It's why it's called OOP, not MOP.
>
> ...
Regardless of how it is called, OOP is definitely not the class.
There are no classes in prototype based OOP languages like SELF and JavaScript (the ES6 "class" gets desugared into prototypes anyway).
There are no classes in pattern based OOP languages like BETA.
There are no classes in type extension based OOP languages like Oberon.
There are no classes in multi-methods/protocol based OOP languages like Common Lisp, Clojure, Dylan and Julia.
There are no classes in interface based OOP languages like VB (pre-.NET), Go, Rust, OCaml.
Basically the OOP design space is big enough to have plain classes define the ultimate meaning of what is OOP.
|