Capturing input-output relation of a function

Stavros Macrakis <[email protected]> Mon, 20 Jan 2025 18:30:07 -0500
Newsgroups gmane.lisp.steel-bank.general
Message-ID <CACLVabWPaeMm8Py6f7Mcfyrc1jq40uXMNqnH944fzWQCUj2HXA@mail.gmail.com>
Given

(defun ff (n) (if (< n 2) 1 (* n (ff (1- n)))))

(ff 3)

I want to capture the input-output pairs:

(ff 1 1)
(ff 2 2)
(ff 3 6)

(let's assume no *errors, throw*s, etc. so a stack works to correlate args
and vals)

But I can't figure out how to capture the function arguments and the
function value.

*trace* doc says

... :CONDITION, :BREAK and :PRINT forms are evaluated in a context which
mocks up the lexical environment of the called function ...


This works to capture argument 0:

(defvar mystack nil)
(trace ff :condition (progn (push (sb-debug:arg 0) mystack) nil))

but

   - how do I capture *all* arguments, or at least know how many there are?
   - how do I capture the return value?

This looks like a job for *advice*, but I couldn't find anything about
*defadvice* on SBCL.

_______________________________________________
Sbcl-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sbcl-help