help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: around advice: why does (and ad-do-it nil) return t?


From: Jambunathan K
Subject: Re: around advice: why does (and ad-do-it nil) return t?
Date: Mon, 13 Feb 2012 18:33:18 +0530
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.93 (windows-nt)

Leo Alekseyev <dnquark@gmail.com> writes:

> Consider the following code:
>
> (defun foobar () t)
> (defadvice foobar (around foobar-advice activate)
>   (and ad-do-it nil))
>
> Evaluating the advised foobar seems to return t.  Why?  Naively, one
> expects (and [whatever] nil) to evaluate to nil!

One possible reason could be this:

(info "(elisp) Around-Advice")
,----
|  -- Variable: ad-do-it
|      This is not really a variable, rather a place-holder that looks
|      like a variable.  You use it in around-advice to specify the place
|      to run the function's original definition and other "earlier"
|      around-advice.
`----

May be you are looking for ad-return-value.

(info "(elisp) Defining Advice")
,----
|  -- Variable: ad-return-value
|      While advice is executing, after the function's original
|      definition has been executed, this variable holds its return
|      value, which will ultimately be returned to the caller after
|      finishing all the advice.  After-advice and around-advice can
|      arrange to return some other value by storing it in this variable.
`----
-- 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]