On Aug 28, 2011, at 12.11 h, Gerd Stolpmann wrote:
Am Sonntag, den 28.08.2011, 11:31 +0200 schrieb Andreas Rossberg:
On Aug 28, 2011, at 01.08 h, Gerd Stolpmann wrote:

Let me point out one final thing. Information hiding is simply not a
core concept of OO - which is in the first place a specific way of
structuring the program (e.g. group data and algorithms together),
with
an integrated method of adapting object types (subtyping), and giving
control of parts of your algorithm to the user of your class.

Not sure why you would say that. I'd argue that information hiding
("encapsulation") definitively is very central to OO -- an object
collects a set of methods that operate on some hidden shared state
(not necessarily mutable). And Ocaml fully supports that.

Who says that the state is or can be hidden? This is certainly a later
addition to OO, when people found out that they can view a class as an
abstract data type (with the known limitations). Take off your "typed
glasses". OO is mainly a way of organizing the execution flow, and there
are lots of OO languages lacking typing and access control.

Again, I don't follow. Alan Kay claims that he invented the term, and his vision of OO was basically that of black boxes communicating through messages. AFAICS, that's also the common picture in OOAD literature. Whether one buys into that is a different story.

Also, none of that has anything to do with types. Objects-as-records- of-closures are a sufficient and pretty natural implementation of this concept.

And even in
OCaml you'd not use objects if your primary interest is encapsulation -
objects are not good at this. (That's all what I'm saying!)

I agree. Modules are superior for most day-to-day things. But then again, a first-class module is pretty much an object with type members, and sometimes one wants first-class modules. ;)

/Andreas


--
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to