Is there any function that gets the name of the function and returns the name of the parameters ?
For example I have a function like this :
(defun test (m n))
I want to get m and n. But I don't want the value of the n and m, Just the name of the parameter "m" and "n".
get parameters name of a function
Re: get parameters name of a function
For a human readable output is the function describe.
Otherwise I recommend you to write a macro for that.
Here is a simple sketch:
Watch out! This is only a sketch it's not a hygienic macro and does a multiple evaluation of its arguments. It's only for defun construct and not for example lambda.
Usage:
Otherwise I recommend you to write a macro for that.
Here is a simple sketch:
Code: Select all
(defmacro my-defun (fname (&rest args) &body body)
`(symbol-macrolet ((lambda-expr ',args))
(defun ,fname ,args ,@body)))
Usage:
Code: Select all
(my-defun plus (a b c)
(format t "~a ~a" (+ a b c) lambda-expr))
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version). Temporary mirrors of aferomentioned: CLHS and a dark version.
Re: get parameters name of a function
Of course, you can use let instead of symbol-macrolet and it's more suitable.
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version). Temporary mirrors of aferomentioned: CLHS and a dark version.
Re: get parameters name of a function
The CL standard does not specify any functions for this type of introspection.
Several CL implementations provide support for it. Search for "defimplementation arglist" in Slime's sources to see how.
Several CL implementations provide support for it. Search for "defimplementation arglist" in Slime's sources to see how.