2 ms·
>Forgive my insistence, but, what kind of problem does the ability to differentiate objects from one another solves? What kind of programs are made simpler by t
by thesz 15y ago
>Forgive my insistence, but, what kind of problem does the ability to differentiate objects from one another solves? What kind of programs are made simpler by this ability?
Oh, I don't know. I am not an expert in OO* at all.
All I know is that for something to be true OO it has to have objects with identities. I was told so. ;)
All I know about OO is Liskov substitution principle. Where it is unnecessary I tend to use State monad and immutable objects.
>subtyping is the basis for polymorphism in OOP.
Which can be solved by several means, interfaces and inheritance being two of them.
- babel17 15y ago> All I know is that for something to be true OO it has to have objects with identities. I was told so. ;) Well, you were told wrong things :-)
- thesz 15y agoPlease, list object-oriented systems with objects with identities and object-oriented systems without those. Count both. Discuss. ;) Alan Kay, who coined term "object-oriented" described object-oriented system as an assembly of objects communicating by message passing. Message passing requires identities (and state, except in severely reduced form).
- babel17 15y agoMessage passing does require a sender, a receiver, and a message. You can have those in purely functional programming. No identity needed. But if you really want one, you can have it: Two objects are identical, if they react to all messages in the same way. You can also explicitly define equality ==, and then say that a and b are identical if a == b.
- thesz 15y ago>Message passing does require a sender, a receiver, and a message. You can have those in purely functional programming. No identity needed. Would you mind show me some code in pure functional language? I mean, in Haskell or Clean. Those are pure enough.
- loup-vaillant 15y agohttp://www.loup-vaillant.fr/articles/classes-as-syntactic-sugar http://www.loup-vaillant.fr/articles/classes-as-syntactic-su... My Ocaml code is not pure, but we can easy remove any occurrence of `ref`, and restricting oneself to pure methods, which produce a new fresh object instead of modifying `this` in place.
- thesz 15y agoSorry, I am not very fluent in OCaml. Also, I didn't find word "message" in the link above. I am experiencing limitations of pure objects and message passing almost right now. In my spare time I am currently developing dynamic data flow CPU which is based on immutable "objects" and message sending. It is quite unusual style of programming, very unlike anything else, including Smalltalk, Erlang and everything.
- loup-vaillant 15y agoIt's like Haskell, with a slightly heavier syntax. And it's eager. And you can unsafePerformIO all over the place (but avoid doing so even in Ocaml). (* Ocaml *) --Haskell let foo = 42 foo = 42 -- top level declaration type bar = data bar = -- type declaration Also, records in Ocaml are a separate kind of type, more like C structs: type bar = { x:int; (* defination *) y:float; } bar.x (* "member" acces *) "Message passing" and "Method calling" are strictly equivalent, at least when everything is synchronous.