From: Ben Morse
Subject: defadvice capability in [SB]CL?
Date: 
Message-ID: <1169420452.890661.160290@l53g2000cwa.googlegroups.com>
Hello!  I'm wondering if there is a facility similar to elisp's advice
system in the CL standard, or failing that, SBCL in particular?
Googling for "Common Lisp" "advice" gets me lots of very helpful stuff,
but not specifically what I'm looking for.

see:
http://www.gnu.org/software/emacs/elisp/html_node/Defining-Advice.html
for what I'm talking about.

Thanks!

-Ben

From: Ken Tilton
Subject: Re: defadvice capability in [SB]CL?
Date: 
Message-ID: <ToSsh.32$Oh7.13@newsfe09.lga>
Ben Morse wrote:
> Hello!  I'm wondering if there is a facility similar to elisp's advice
> system in the CL standard, or failing that, SBCL in particular?
> Googling for "Common Lisp" "advice" gets me lots of very helpful stuff,
> but not specifically what I'm looking for.

How about "advise"?

kt

-- 
The Dalai Lama gets the same crap all the time.
   -- Kenny Tilton on c.l.l when accused of immodesty
From: Ben Morse
Subject: Re: defadvice capability in [SB]CL?
Date: 
Message-ID: <1169421357.529372.205630@l53g2000cwa.googlegroups.com>
Ken Tilton wrote:
> How about "advise"?

Hmm, is that an Allegro-only thing?  Because it looks to be pretty much
exactly what I want.

Probably time to download an evaluation version...
From: Thibault Langlois
Subject: Re: defadvice capability in [SB]CL?
Date: 
Message-ID: <1169423462.182101.313950@l53g2000cwa.googlegroups.com>
On Jan 21, 11:15 pm, "Ben Morse" <········@gmail.com> wrote:
> Ken Tilton wrote:
> > How about "advise"?Hmm, is that an Allegro-only thing?  Because it looks to be pretty much
> exactly what I want.
>
> Probably time to download an evaluation version...

Have you seen this:

http://common-lisp.net/project/cmucl/doc/cmu-user/extensions.html#toc83

it looks pretty close to what you are looking for (I think)

Maybe SBCL use the same mechanism to implement TRACE .

Thibault
From: Ben Morse
Subject: Re: defadvice capability in [SB]CL?
Date: 
Message-ID: <1169447898.020662.75360@51g2000cwl.googlegroups.com>
Thibault Langlois wrote:
> Have you seen this:
>
> http://common-lisp.net/project/cmucl/doc/cmu-user/extensions.html#toc83
>
> it looks pretty close to what you are looking for (I think)
>
> Maybe SBCL use the same mechanism to implement TRACE .
>
> Thibault

Ah, neat!  Yes, that's pretty much what I was looking for...  Chasing
down TRACE on sbcl-internals verifies that sbcl doesn't expose
fwrappers, so I think I'm out of luck for the moment, but maybe I'll
take a couple days to play with CMUCL next weekend.

Thanks!
-Ben
From: Duane Rettig
Subject: Re: defadvice capability in [SB]CL?
Date: 
Message-ID: <o03b63uiem.fsf@gemini.franz.com>
"Ben Morse" <········@gmail.com> writes:

> Thibault Langlois wrote:
>> Have you seen this:
>>
>> http://common-lisp.net/project/cmucl/doc/cmu-user/extensions.html#toc83
>>
>> it looks pretty close to what you are looking for (I think)
>>
>> Maybe SBCL use the same mechanism to implement TRACE .
>>
>> Thibault
>
> Ah, neat!  Yes, that's pretty much what I was looking for...  Chasing
> down TRACE on sbcl-internals verifies that sbcl doesn't expose
> fwrappers, so I think I'm out of luck for the moment,

That's because some CMUCL developer didn't attribute the fwrap concept
to where they got it from - it's been in Allegro CL since version 6.0
in 2000 (our code base dates back to 1999):
http://www.franz.com/support/documentation/6.0/doc/fwrappers-and-advice.htm
All of the interface is effectively the same, even down to most of the
names (except that call-next-fwrapper is called call-next-function).
I've never mentioned it because in general I like to see my ideas
promulgated in other lisps; it's just too bad there are no
attributions to having gotten the idea from Allegro CL.

> but maybe I'll
> take a couple days to play with CMUCL next weekend.

You might also want to grab the free Express Edititon of Allegro CL;
it also has fwrappers.  I'm not sure how fwrappers work in CMUCL, but
they are extremely efficient in Allegro CL - the function's code
itself is not modified at all, and the "wrapping" is done in sort of
an inside-out manner, with minimal consing of arguments (attempts are
made to pass stack-addresses rather than consing up argument lists as
fwrappers are invoked).

-- 
Duane Rettig    ·····@franz.com    Franz Inc.  http://www.franz.com/
555 12th St., Suite 1450               http://www.555citycenter.com/
Oakland, Ca. 94607        Phone: (510) 452-2000; Fax: (510) 452-0182   
From: Ken Tilton
Subject: Re: defadvice capability in [SB]CL?
Date: 
Message-ID: <__Ssh.44$9S.5@newsfe11.lga>
Ben Morse wrote:
> Ken Tilton wrote:
> 
>>How about "advise"?
> 
> 
> Hmm, is that an Allegro-only thing? 

Oops. I did not notice that that was ACL doc called up when I hit F1. I 
have never used the mechanism, and I thought it was ancient Lisp. I 
guess not.

Macrology or GFs won't do?

kt

-- 
The Dalai Lama gets the same crap all the time.
   -- Kenny Tilton on c.l.l when accused of immodesty
From: Ben Morse
Subject: Re: defadvice capability in [SB]CL?
Date: 
Message-ID: <1169447473.289795.235910@m58g2000cwm.googlegroups.com>
Ken Tilton wrote:
> Oops. I did not notice that that was ACL doc called up when I hit F1. I
> have never used the mechanism, and I thought it was ancient Lisp. I
> guess not.
>
> Macrology or GFs won't do?

Good call - I'm pretty junior as far as CL goes, so I can probably use
all the macro practice I can get.  For the moment I'd only be using
this around specific functions, so I suppose I could change them from
defuns to defadvisables and run from there.  Generics would certainly
do the trick, and in the long run, that'll probably be what I end up
using.  At the moment, though, I'm coming from a C++ background and I
still haven't really managed to absorb CLOS, so I'd like to build
familiarity with simple stuff that I actually understand the underlying
implementation of.

Thanks for your help, Ken!

- Ben
From: Ken Tilton
Subject: Re: defadvice capability in [SB]CL?
Date: 
Message-ID: <760th.115$Up.31@newsfe12.lga>
Ben Morse wrote:
> Ken Tilton wrote:
> 
>>Oops. I did not notice that that was ACL doc called up when I hit F1. I
>>have never used the mechanism, and I thought it was ancient Lisp. I
>>guess not.
>>
>>Macrology or GFs won't do?
> 
> 
> Good call - I'm pretty junior as far as CL goes, so I can probably use
> all the macro practice I can get.  For the moment I'd only be using
> this around specific functions, so I suppose I could change them from
> defuns to defadvisables and run from there.  Generics would certainly
> do the trick, and in the long run, that'll probably be what I end up
> using.  At the moment, though, I'm coming from a C++ background and I
> still haven't really managed to absorb CLOS, so I'd like to build
> familiarity with simple stuff that I actually understand the underlying
> implementation of.

Of course it is your learning experience, but I am puzzled: you are 
going to learn yet another non-portable CL mechanism (guessing it will 
not be the same as elisp's) and even switch CLs rather than use this as 
motivation to learn some standard CL you plan to learn anyway? Me, I am 
always grateful when a bona fide application of X comes along when I 
have been meaning to learn X but putting it off.

kzo


-- 
The Dalai Lama gets the same crap all the time.
   -- Kenny Tilton on c.l.l when accused of immodesty
From: Tim X
Subject: Re: defadvice capability in [SB]CL?
Date: 
Message-ID: <87fya3h4zf.fsf@lion.rapttech.com.au>
Ken Tilton <·········@gmail.com> writes:

> Ben Morse wrote:
>> Ken Tilton wrote:
>>
>>>How about "advise"?
>>
>>
>> Hmm, is that an Allegro-only thing? 
>
> Oops. I did not notice that that was ACL doc called up when I hit F1. I have
> never used the mechanism, and I thought it was ancient Lisp. I guess not.
>
> Macrology or GFs won't do?
>

Actually, you can do it with a macro. In fact, this is how elisp does it. I
"rolled my own" defadvice in CL - well at least I started to and I've probably
still got the code here somewhere, but it must be on my old system as its not
in the archives on this machine. If I get time, I'll go back through my backups
and see if I can find it (though it will probably show you more about how not
to do it than anything else!). However, once I got into CL a bit, I found I
didn't really need it and given I was still learning about macros and was
getting bitten by subtle points I wasn't quite knowledgeable enough yet to
fully understand, I put the project aside until I got a bit more proficient
with CL. Since then, I've never needed it, so I've never gone back to work on
it. 

My suggestion would be to have a look at the advice.el source file. This should
give you some ideas. You can then try porting it to CL and when you get into
trouble, post here for some help. It would probably also be a good idea to
provide some background as to why you want this facility - my experience has
been that often there are more CL'ish ways to achieve what you want. 

HTH

Tim
-- 
tcross (at) rapttech dot com dot au