Lets say i want to get the documentation for a function, I'd say
(documentation 'foo 'function)
but what if I only had foo and function as strings? E.g. "foo" and "function".
What would I have to do to them to make them usable as parameters to the documentation call?
[Side note: I'm using clisp, but I doubt that matters.]
Use FIND-SYMBOL, not INTERN. If you want to find documentation for an existing function, finding a symbol is enough. INTERN also creates symbols.
CL-USER > (find-symbol "SIN" "COMMON-LISP")
SIN
:EXTERNAL
Note that Common Lisp symbols are uppercase internally be default. Thus you need to use an uppercase string to find the corresponding symbol in the corresponding package.
Also note that there actually isn't something like a 'quoted variable'. You want to convert a string to a symbol.
Use INTERN to convert a string to a symbol. Make sure you uppercase the strings because, unlike with symbols, the reader will not do it for you:
(tested in SBCL):
* (documentation 'mapcar 'function)
"Apply FUNCTION to successive elements of LIST. Return list of FUNCTION
return values."
* (documentation (intern "MAPCAR") (intern "FUNCTION"))
"Apply FUNCTION to successive elements of LIST. Return list of FUNCTION
return values."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With