Re: To CLOS or not to CLOS?
P T Withington <[email protected]>
| Newsgroups | gmane.comp.lang.lightweight |
|---|---|
| Message-ID | <[email protected]> |
On 2007-02-20, at 15:31 EST, [email protected] wrote: > - Are generic functions really the right or only way to go? It > seems many > of CLOS's advantages could still be had in a object-dispatched object > system designed with a similar mentality, and perhaps there are > advantages > to object-dispatch. The only advantage I can think of is that it takes fewer cpu cycles. But as I have said in the past: cpu cycles we have plenty of, it is good programmer cycles we need to optimize. Craig Chambers and Jonathan Bachrach both have a lot to say about a) how to optimize generic dispatch and b) why some languages chose not to implement generic dispatch. Generic functions are the evolution of object (or message) dispatch to solve the problem of which object a method belongs to when it operates on more than one object. If you artificially attach it to one of its argument objects, you have to simulate generic dispatch on the remaining arguments. (Some will argue that this is a rare enough occurrence that you don't need a special language mechanism to handle it. But by the same token, who needs bignums or garbage collection?) One thing that CLOS got wrong, which was improved in Dylan, is how to choose the most applicable method of a generic function. The Dylan improvement was the fruit of research started by Ducournau, Habib, et al. See http://en.wikipedia.org/wiki/C3_linearization for more.