From: ······@pupeno.com
Subject: Why are :after and :before ordered this way
Date: 
Message-ID: <1188601843.879701.57790@g4g2000hsf.googlegroups.com>
Hello,

I'm refreshing my knowledge of CLOS and I see that :before methods are
run from less-specific to more-specific and :after methods in the
reverse direction. Although I can see some arguments in favor of these
directions, I can also see them in favor of the reverse direction. Is
there any particular strong reason why they are done this way?

Thank you.

From: Ken Tilton
Subject: Re: Why are :after and :before ordered this way
Date: 
Message-ID: <mB2Ci.272$ph.247@newsfe12.lga>
······@pupeno.com wrote:
> Hello,
> 
> I'm refreshing my knowledge of CLOS and I see that :before methods are
> run from less-specific to more-specific and :after methods in the
> reverse direction. Although I can see some arguments in favor of these
> directions, I can also see them in favor of the reverse direction. Is
> there any particular strong reason why they are done this way?

You are right and wrong. The reverse of what you describe makes more 
sense, and is in fact how they work.

kt

-- 
http://www.theoryyalgebra.com/

"We are what we pretend to be." -Kurt Vonnegut
From: Rainer Joswig
Subject: Re: Why are :after and :before ordered this way
Date: 
Message-ID: <joswig-686521.01224301092007@news-europe.giganews.com>
In article <·······················@g4g2000hsf.googlegroups.com>,
 ·······@pupeno.com" <······@pupeno.com> wrote:

> Hello,
> 
> I'm refreshing my knowledge of CLOS and I see that :before methods are
> run from less-specific to more-specific and :after methods in the
> reverse direction.

No.

> Although I can see some arguments in favor of these
> directions, I can also see them in favor of the reverse direction. Is
> there any particular strong reason why they are done this way?
> 
> Thank you.

:before methods: most-specific first
:after methods: most-specific last
From: Barry Margolin
Subject: Re: Why are :after and :before ordered this way
Date: 
Message-ID: <barmar-B1D253.21264331082007@comcast.dca.giganews.com>
In article <····························@news-europe.giganews.com>,
 Rainer Joswig <······@lisp.de> wrote:

> In article <·······················@g4g2000hsf.googlegroups.com>,
>  ·······@pupeno.com" <······@pupeno.com> wrote:
> 
> > Hello,
> > 
> > I'm refreshing my knowledge of CLOS and I see that :before methods are
> > run from less-specific to more-specific and :after methods in the
> > reverse direction.
> 
> No.
> 
> > Although I can see some arguments in favor of these
> > directions, I can also see them in favor of the reverse direction. Is
> > there any particular strong reason why they are done this way?
> > 
> > Thank you.
> 
> :before methods: most-specific first
> :after methods: most-specific last

And the reason for this ordering is that it's the most natural way to 
layer classes.  In languages that don't have automatic method 
combinations, you typically do it explicitly in the code, using their 
equivalent of CALL-NEXT-METHOD to call the method of the superclass.  So 
one usually writes something analogous to:

(defmethod foo (...)
   <before stuff>
   (call-next-method)
   <after stuff>)

CLOS simply allows you to write the <before stuff> and <after stuff> by 
themselves, and it automcatically constructs the combined method (it 
originally came from Flavors, which didn't have a CALL-NEXT-METHOD, so 
you *had* to use :before/:after for this).

But the goal is essentially the same, and so is the layering logic.  Whe 
you define a subclass, you typically want all the superclass's behavior, 
but may want to add things on.  By wrapping your new functionality 
around the old function, you ensure that you don't interfere with its 
behavior.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
From: ······@pupeno.com
Subject: Re: Why are :after and :before ordered this way
Date: 
Message-ID: <1188649077.544572.164540@19g2000hsx.googlegroups.com>
Rainer Joswig wrote:
> In article <·······················@g4g2000hsf.googlegroups.com>,
>  ·······@pupeno.com" <······@pupeno.com> wrote:
> > Although I can see some arguments in favor of these
> > directions, I can also see them in favor of the reverse direction. Is
> > there any particular strong reason why they are done this way?
> >
> > Thank you.
>
> :before methods: most-specific first
> :after methods: most-specific last

Oops, right. Thank you. I've made a diagram of the CL method
composition. Just so me and other newbies can hang it on the wall
until it is recorded on some part of the brain:

http://files.pupeno.com/cl/

What do you think? Did I get it right this time?
From: Rainer Joswig
Subject: Re: Why are :after and :before ordered this way
Date: 
Message-ID: <joswig-99EC69.15182001092007@news-europe.giganews.com>
In article <························@19g2000hsx.googlegroups.com>,
 ·······@pupeno.com" <······@pupeno.com> wrote:

> Rainer Joswig wrote:
> > In article <·······················@g4g2000hsf.googlegroups.com>,
> >  ·······@pupeno.com" <······@pupeno.com> wrote:
> > > Although I can see some arguments in favor of these
> > > directions, I can also see them in favor of the reverse direction. Is
> > > there any particular strong reason why they are done this way?
> > >
> > > Thank you.
> >
> > :before methods: most-specific first
> > :after methods: most-specific last
> 
> Oops, right. Thank you. I've made a diagram of the CL method
> composition. Just so me and other newbies can hang it on the wall
> until it is recorded on some part of the brain:
> 
> http://files.pupeno.com/cl/
> 
> What do you think? Did I get it right this time?

Looks better.

How about this one:

http://lispm.dyndns.org/lisp/pics/clos1.jpg

This also does not reflect that methods don't belong to classes...

-- 
http://lispm.dyndns.org
From: GP lisper
Subject: Re: Why are :after and :before ordered this way
Date: 
Message-ID: <slrnfdpgnj.bho.spambait@phoenix.clouddancer.com>
On Sat, 01 Sep 2007 15:18:21 +0200, <······@lisp.de> wrote:
> In article <························@19g2000hsx.googlegroups.com>,
>  ·······@pupeno.com" <······@pupeno.com> wrote:
>
>> Rainer Joswig wrote:
>> > In article <·······················@g4g2000hsf.googlegroups.com>,
>> >  ·······@pupeno.com" <······@pupeno.com> wrote:
>> >
>> > :before methods: most-specific first
>> > :after methods: most-specific last
>> 
>> Oops, right. Thank you. I've made a diagram of the CL method
>> composition. Just so me and other newbies can hang it on the wall
>> until it is recorded on some part of the brain:
>> 
>> http://files.pupeno.com/cl/
>> 
>> What do you think? Did I get it right this time?

I like it, and it matches what I just reread in Keene.  I need to fix
it a bit since my desktop doesn't have a white background in a lower
layer.  You might want to change 'inherit' to 'inherits'.  It's good
to see the call-next-method reminder, since otherwise the chain is
broken.


> How about this one:
>
> http://lispm.dyndns.org/lisp/pics/clos1.jpg

I confused how the multistates are separated, how state 7 differs from
11, or 3 from 15, and the other collisions.  I think you are showing
something different than ordering.


-- 
Lisp:  Powering `Impossible Thoughts since 1958

-- 
Posted via a free Usenet account from http://www.teranews.com
From: Tim Bradshaw
Subject: Re: Why are :after and :before ordered this way
Date: 
Message-ID: <1188997567.450872.5600@k79g2000hse.googlegroups.com>
On Sep 1, 12:10 am, ·······@pupeno.com" <······@pupeno.com> wrote:
> Hello,
>
> I'm refreshing my knowledge of CLOS and I see that :before methods are
> run from less-specific to more-specific and :after methods in the
> reverse direction. Although I can see some arguments in favor of these
> directions, I can also see them in favor of the reverse direction. Is
> there any particular strong reason why they are done this way?

As others have said, you have the ordering backwards.  I think the
standard ordering is the most commonly useful, but there are cases
where the reverse is useful as well.  Fortunately CLOS makes this
(reasonably) easy: you can define your own method combintion.
http://www.tfeb.org/lisp/hax.html#WRAPPING-STANDARD gives an example
of a method combination which provides "wrapping" methods, which are
like around methods but run in the reverse order - most-specific
innermost.

--tim