Skip to content

Commit

Permalink
Added example foo function, updated advise callsites
Browse files Browse the repository at this point in the history
  • Loading branch information
jkordani authored and xrme committed Apr 22, 2024
1 parent db68b3f commit 304bfcd
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions doc/manual/debugging.ccldoc
Original file line number Diff line number Diff line change
Expand Up @@ -326,14 +326,20 @@ error is signaled.")
")))
(defsection "Examples"
(para "
The function {code foo}, already defined, does
something with a list of numbers. The following code uses a
With the function {code foo} defined as follows
"
(code-block "
(defun foo (numlist)
(apply '+ numlist))
")
"
The following code uses a
piece of advice to make foo return zero if any of its
arguments is not a number. Using :around advice, you can do
the following:
"
(code-block "
(advise foo (if (some #'(lambda (n) (not (numberp n))) arglist)
(advise foo (if (some #'(lambda (n) (not (numberp n))) (car arglist))
0
(:do-it))
:when :around :name :zero-if-not-nums)
Expand All @@ -342,7 +348,7 @@ error is signaled.")
To do the same thing using a :before piece of advice:
"
(code-block "
(advise foo (if (some #'(lambda (n) (not (numberp n))) arglist)
(advise foo (if (some #'(lambda (n) (not (numberp n))) (car arglist))
(return 0))
:when :before :name :zero-if-not-nums)
"))))
Expand Down

0 comments on commit 304bfcd

Please sign in to comment.