2 ms·
Encapsulation can also be handled well at the module/package system level, though Yes, it's more or less the same, but you can define public and private parts
by narag 18y ago
Encapsulation can also be handled well at the module/package system level, though
Yes, it's more or less the same, but you can define public and private parts for individual objects. The good part of encapsulation is separating interface from implementation: you can publish a data type without giving access to its innards.
sometimes there isn't a clear answer which object should be the primary one in a binary operation
I really haven't found it to be a problem in practice.
- silentbicycle 18y agoThe good part of encapsulation is separating interface from implementation: you can publish a data type without giving access to its innards. And you can do that in a good module system, too. Look at OCaml's. (http://caml.inria.fr/pub/docs/manual-ocaml/manual004.html http://caml.inria.fr/pub/docs/manual-ocaml/manual004.html) Also, look at the functors - modules are first class, so you can write functions that take a module and return a (usually more specific or generated) module.