lispdevelopment-environmentallegro-cl

browse definitions in LISP


I am very new to LISP. I am using allegro-cl. I am having difficulty calling a function I have defined and loaded. I would like to know what are some ways I can browse the things I have defined, for instance listing all methods in a certain package, or listing just variables, or listing package names, etc.


Solution

  • I'm not using Allegro CL, so I can only tell you about the tools CL itself provides for this. You might want to check what the Allegro CL IDE has to offer for this task.

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

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

    CL packages are collections of symbols (i.e. names), not the objects associated with these names. You have to query the names in them further to see if there's a value and/or a function defined for that symbol. You can use DO-SYMBOLS to loop over all the symbols in a package. This would print all the symbols in the current package:

    (do-symbols (s) (print s)
    

    this only the functions:

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

    and this only the functions whose home package is the current package:

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