Generics vs. Message passing: object namespaces
Tom Locke <[email protected]>
| Newsgroups | gmane.comp.lang.lightweight |
|---|---|
| Message-ID | <[email protected]> |
I may well have missed it, but in all this talk of generic-function
based OO vs. message-passing OO, what about the issue of namespaces
scoped to objects.
e.g.
buffer.append(x) vs. append_to_buffer(buffer, x)
I believe I am correct in stating that the generic function style
requires the latter? Sharing a single generic function "append" among
the very wide range of objects that might provide a definition isn't
workable. Maybe someone will pull me up on this particular example,
but one only has to take a look at any CLOS or Dylan code to see that
the issue is real.
To my mind one of the chief benefits of the OO style is in
organisation of code. We put things in places that makes sense, and
we find them easily later. Yes this breaks down if a method belongs
equally in two places, but it's still a big net win IMO.
In message-passing style OO, it's often possible to simply guess the
method name, and there is often support in the editor for enumerating
the available methods. So writing is easier. Reading is easier too -
that "_to_buffer" in the above example is largely noise. Noise that
adds up pretty quickly.
I wonder if language designers, with their theoretical bent, find
this issue of little importance - to a mathematician, a name is just
a name. As long as it is distinct, what else matters? To us humans,
it matters a lot!
As I said - maybe this issue did already get raised -- maybe in
language too fancy for me to notice ;-) Either way, from a pragmatic
point of view, I'd say this is issue numero uno, so some extra
clarity would be very interesting.
Proponents of CLOS - what say you?
Tom