3 ms·
> One can ask Lisp about all that then How? As in what commands/functions/macros? Say I define a function and compile with slime, how do I get the repl to pri
by leprechaun1066 5y ago
> One can ask Lisp about all that then
How? As in what commands/functions/macros?
Say I define a function and compile with slime, how do I get the repl to print it back to me? And with a function I loaded from an external library? Is there something like macroexpand-1 for functions which will print it out?
- lispm 5y agoM-. on a symbol brings you to the source code. Common Lisp also has built in the function FUNCTION-LAMBDA-EXPRESSION, which returns the source for a function -> when Lisp has recorded its definition. Try (DESCRIBE #'some-function) in SBCL to get information about the arglist, the types, the source file. In a SLIME editor buffer try c-h m . This will display the buffer commands. There are a zillion of commands to get information about the symbols, code references, etc. On my Lisp Machine: Command: Show Source Code (a defined function spec) mts::init-facts Source code for MTS::INIT-FACTS: (defun init-facts () (setf *init-facts* '((world (loc (actor joe) (val cave))) (joe (loc (actor joe) (val cave))) (world (loc (actor irving) (val oak-tree))) (irving (loc (actor irving) (val oak-tree))) (joe (loc (actor irving) (val oak-tree))) (world (loc (actor water) (val river))) (joe (loc (actor water) (val river))) (world (loc (actor honey) (val elm-tree))) (irving (loc (actor honey) (val elm-tree))) (world (loc (actor worm) (val ground))) (joe (loc (actor worm) (val ground))) (irving (loc (actor joe) (val cave))) (world (loc (actor fish) (val river))) (irving (loc (actor fish) (val river)))))) Command: Show Callers (a symbol [default MTS::INIT-FACTS]) MTS::INIT-FACTS MTS::MICRO-TALESPIN calls MTS::INIT-FACTS as a function. MTS::MICRO-TALESPIN-DEMO calls MTS::INIT-FACTS as a function. Done. Command: