View definitions in LISP

I am very new to LISP. I am using allegro-cl. It's hard for me to call a function that I defined and loaded. I would like to know in what ways I can view what I have defined, for example, listing all methods in a specific package or listing only variables, or listing package names, etc.

+4
source share
3 answers

I do not use Allegro CL, so I can only tell you about the tools that CL itself provides. You can check what the Allegro CL IDE offers for this task.

You can get a list of all packages with the LIST-ALL-PACKAGES function. You can use it to print your names:

(dolist (p (list-all-packages)) (write-line (package-name p))) 

CL packages are collections of characters (such as names), not the objects associated with these names. You should request the names in them further to find out if there is a value and / or function defined for this symbol. You can use DO-SYMBOLS to iterate over all the characters in a packet. This will print all the characters in the current batch:

 (do-symbols (s) (print s) 

these are just the functions:

 (do-symbols (s) (when (fboundp s) (print s))) 

and these are only those functions whose home package is the current package:

 (do-symbols (s) (when (and (eq (symbol-package s) *package*) (fboundp s)) (print s))) 
+4
source

If you remember part of the name, you can always use APROPOS (possibly limited to a specific package) to find the full name.

+3
source

I ran into the same problem. After reading the documentation, I came to the conclusion that there is no way to recall the definition introduced in the REPL.

To get around this problem, I always type in the editor window (Ctrl + N, if not). That way I can type definitions, edit them, etc. With great convenience. If I need to evaluate the definition, I press Ctrl + E to incrementally evaluate (see Other options in the Tools menu). I leave the listener window on the left and the editor window on the right to see the inputs and outputs.

There is still a small problem that may cause some errors: if you forget to evaluate the definition after making changes to it, the old one remains in the REPL. Continue to press Ctrl + E.

If you have several files open and you want to find the definition in one of the source files, you can use Search> Apropos.

0
source

Source: https://habr.com/ru/post/1336828/


All Articles