Re: Generics vs. Message passing: object namespaces

Douglas Philips <[email protected]> Sat, 24 Feb 2007 10:07:03 -0500
Newsgroups gmane.comp.lang.lightweight
Message-ID <[email protected]>
> Is this good CLOS or bad CLOS? How about we rename those accessors  
> to "name" and "age"? Good or bad?

Question is underspecified. The assumption at work here is that there  
is just one big glommed together name-space. Pascal has already  
attempted to address that issue. Single object dispatch lets you  
pretend that you don't have name space issues, but that doesn't  
reduce the cognitive load on a programmer faced with a module in  
which there are many different kinds/species of 'draw' methods being  
invoked.


> 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.

The examples we've been using are so toy that such a simplistic  
approach works. Almost. If you look at, say, C++'s dispatch, you'll  
find that "cout << myObject" (cout.operator<<(myObject)) is not what  
you want. Given the number of papers you can find via <search engine  
du jour> on multi-dispatch this is hardly a trivial issue and it is  
not limited to any particular language's implementation of object  
dispatch. It is a fundamental limitation of single parameter ("the"  
object) dispatch. The Visitor Pattern and other sorts of manual multi- 
dispatch may be ways to work around it, but that is just trading  
programmer time and effort to overcome a language deficiency.

Regardless, 'file.name' is a bit disingenuous. It is using the name  
of the variable to convey type information to a human reader. The  
compiler has no such bias. Hence the abuse of this technique in  
obsfucated code. So while you find it OK to say 'file.name', you  
object to '(file:name myObject ...)'? I am not clear on what the  
actual grounds for objection are. There is no need to qualify 'name'  
in a module/function/etc. unless there is ambiguity about which  
species of 'name' you want.


But this is approaching the pointless. Quoting Stroustrup:
	<http://www.research.att.com/~bs/bs_faq.html#compare>
	"I also worry about a phenomenon I have repeatedly observed in honest
	attempts at language comparisons. The authors try hard to be impartial,
	but are hopelessly biased by focusing on a single application, a single
	style of programming, or a single culture among programmers.
	Worse, when one language is significantly better known than others,
	a subtle shift in perspective occurs: Flaws in the well-known language
	are deemed minor and simple workarounds are presented, whereas similar
	flaws in other languages are deemed fundamental. Often, the workarounds
	commonly used in the less-well-known languages are simply unknown to  
the
	people doing the comparison or deemed unsatisfactory because they would
	be unworkable in the more familiar language."


--Doug