Re: Generics vs. Message passing: object namespaces
Tom Locke <[email protected]> Sat, 24 Feb 2007 11:59:26 +0000
| Newsgroups | gmane.comp.lang.lightweight |
|---|---|
| Message-ID | <[email protected]> |
Nice to see this topic has generated some interest :-)
Can I break this down into words of two syllables or less?
The following (darn - blew it already) guide:
http://www.aiai.ed.ac.uk/~jeff/clos-guide.html
Contains:
------
A defclass that provided similar access functions, etc, would be:
(defclass person ()
((name :accessor person-name
:initform 'bill
:initarg :name)
(age :accessor person-age
:initform 10
:initarg :age)))
------
Is this good CLOS or bad CLOS? How about we rename those accessors to
"name" and "age"? Good or bad?
There is some interesting discussion of this point in the context of
Dylan here:
http://www.opendylan.org/books/dpg/db_125.html
Quote: "Therefore, for getters that you intend to export, it makes
sense prevent clashes by considering the name of the slot carefully.
One technique is to prefix the name of the property with the name of
the class"
And a couple of general points...
In practice, programmers using object-dispatch languages have no
difficulty understanding where a call is going when the see something
like "file.name". Yes the namespace is implicit rather than explicit,
but people are good at context! Honestly, this is a BIG reason why
people like object-dispatch. It is. Honestly.
Can we try to avoid this degenerating into "my language is better
than your language"? The question at hand relates to a very specific
comparison of the two styles. The answer I'm hoping for is either
"no, this is not a valid advantage of object-dispatch because ...",
or "yes, that's one advantage object-dispatch has". If the answer
turns out to be the latter, feel free to append "but overall I still
prefer generic-functions because ...", if that makes you happier :-)
Tom