Let's say you want to get the lambda list of every function in a package. On SBCL, using iterate you could do this
(use-package :iterate)
(defun lambda-lists (package)
(iter (for symbol in-package (find-package package))
(collect (sb-introspect:function-type symbol))))
To be more portable you might try something like this
(defun lambda-lists (package)
(iter (for symbol in-package (find-package package))
(collect (function-lambda-expression symbol))))
But this won't work since function-lambda-expression takes a function, not a symbol.
Something like (function symbol) won't work either since it makes a function called symbol, not a function called the value of symbol.
Is there a way to realize this with macro?
CodePudding user response:
First you need to find out which symbol denotes a global function and not a macro or special form. See: FBOUNDP, MACRO-FUNCTION, SPECIAL-OPERATOR-P
Then you need to retrieve the function from the symbol: use SYMBOL-FUNCTION.
