On Mar 24, 5:37 pm, Meikel Brandmeyer <m...@kotka.de> wrote:
> Hi,
>
> Am 24.03.2009 um 22:36 schrieb mikel:
>
> > CLOS says that if two matches are otherwise equally specific, the one
> > on the left wins. Similarly, it says that if two classes define slots
> > with the same name, the one farthest from the root of the class
> > heterarchy (as defined by a standard traversal algorithm) wins. You
> > can make a theoretical argument that these choices are arbitrary, and
> > that the programmer should control those decisions. In practice, the
> > CLOS approach is not a problem because:
>
> Thank you for the long explanation. Please allow me to be sceptical
> (fatigued and after all long day of work). CLOS is certainly a powerful
> system, but reading these rules makes me headaches.
>
> To use a gf I need to understand, which dispatch sequence, graph
> traversing algorithms or class definition orders are used. I will almost
> certainly mess this up. I personally prefer the explicit style, where I
> declare which method to prefer over another. So I don't have to rely
> on my leaky memory.
>
> But this is only some fuzzy feeling. I will certainly try gf when I'm
> in a more awaken state.

I know what you mean. My own experience of learning CLOS lo, these
many years ago was that the explanations seemed sort of impenetrable,
but that when I started actually using it, it was quite
straightforward and easy to understand. In practice, the only time
I've needed to understand anything about the mechanics of dispatch and
applicable method ordering is when I'm implementing them.

Applied to 11, a method on Integer is more specific than a method on
Number, which is more specific than a method on Object.

If your method on Integer calls next-method, then in that case, next-
method is the method on Number.

Applied to [1 2], a method on [Integer Number] is more specific than a
method on [Number Integer], because the more specific class "comes
first".

That's pretty much to all you need to know to use generic functions
productively. There are more esoteric things to learn about them if
you want to do esoteric things, but the circumstances where one needs
to do those things tend to be...esoteric.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to