[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Portable way to get a function's arg list AND DOC STRING??
| Date: Mon, 23 March 1992, 18:14 -0500
| From: Barry Margolin
| Date: Mon, 23 Mar 1992 17:03 EST
| From: Healy@space50.nrl.navy.mil (Liam M. Healy)
| Date: Mon, 23 Mar 1992 16:40 EST
| From: email@example.com (Marty Hall)
| Is there a portable way to get the parameter list to a function?
| Ie I want a way to be able to tell the user that function Foo
| has two required args named xxx and yyy and one &optional arg
| named zzz with a default value of aaa, just as Symbolics does
| with control-shift-A (and elsewhere). I tried to see how Symbolics did
| it, but I couldn't find anything portable, especially as I'm not
| allowed to assume anything about the structure of the object "function"
| or "symbol-function" returns (right?). IS there a way?
| I assume the answer is "no", but I wanted to confirm this with the
| - Marty
| (setf (need-p 'disclaimer) NIL)
| arglist, e.g.: (arglist 'foo) returns information on function foo.
| As near as I can tell this is Symbolics, not CL. But I'm no
| There is no fully portable function that does this. But I'll bet
| several other CL implementations have an ARGLIST function. Lucid does.
ARGLIST isn't in CLtL2, but most of the vendors seem to offer a function
that does what you want, Marty. I have used the piece of GNU Emacs Lisp
code shown below for some time now to extract info on a Lisp function
over the network from one of our Lispms (a TI explorer II and a
Symbolics 3640) while sitting in GNU Emacs on a Unix box. I bind the
function to "C-h f" when in Common Lisp mode.
Now a related problem that I hope some of the Genera Gurus can solve:
- How can you extract the documentation string from CL functions defined
in Genera? What I want is a programmatic interface to the CP command
"Show Documentation". CLtL2 specifies DOCUMENTATION as a good candidate
function, and this works fine with our TI Explorer, but Genera uses the
document examiner for that. Moreover, in my version of Genera (8.0)
there is no sources available for SAGE::COM-SHOW-DOCUMENTATION or
Eyvind Ness Internet Email: firstname.lastname@example.org
Research Scientist Phone: +47 9 183100
Control Room Systems Division Fax: +47 9 187109
OECD Halden Reactor Project Surface Mail: P.O. Box 173, N-1751 Halden
Here is the GNU Emacs Lisp extension function to extract info on a
remotely defined CL function:
(defun rld-describe-function (function &optional doc-host)
"Display the documentation of FUNCTION [supplied by DOC-HOST]."
(let ((fn (rld-function-called-at-point))
(if fn (format "Describe function (default %s): " fn)
"Describe function: ")
obarray 'fboundp nil))
(list (if (equal val "") fn (intern val)))))
(let ((symname (symbol-name function))
(setq doc-host (rpc-hm-get-current-host)))
"(format nil \"Function ~A:~A ~:A~\%~\%~8T~A\" "
;; ~% has to be \-ed, to avoid elisp interference.
"(package-name (symbol-package '" symname "))"
"(symbol-name '" symname ")"
"(if (fboundp '" symname ")" "(arglist '" symname ")"
"\"[Not a Function]\")"
"(or (documentation '" symname " 'function)"
"\"[Not documented]\" ))"
) 'invoke-reader ':any))
(set-buffer (get-buffer-create "*Documentation Output*"))
";;; End of documentation for "
" provided by "
(if (stringp doc-host) doc-host
(display-buffer "*Documentation Output*"))))))
The function uses a util I've made, RPC-HM-INTERNAL, which does the
actual work of communicating with the Lispms. I plan to put this code
into the public domain as a contribution to the Elisp archive for GNU
Emacs, but I need some more time to clean it up first (and make sure
there is no equivalent util around that does this already).