Skip to content

Instantly share code, notes, and snippets.

@phoe
Created January 26, 2022 13:23
Show Gist options
  • Save phoe/25b2fe40265400a9d64e6d0684bb0b3a to your computer and use it in GitHub Desktop.
Save phoe/25b2fe40265400a9d64e6d0684bb0b3a to your computer and use it in GitHub Desktop.
List all SBCL packages, private, and public ones
(defun starts-with (string substring)
(let ((length (length substring)))
(and (<= length (length string))
(string= (subseq string 0 length) substring))))
(defun list-all-sbcl-packages ()
(flet ((sbcl-package-p (package)
(starts-with (package-name package) "SB-")))
(remove-if-not #'sbcl-package-p (list-all-packages))))
(defun private-sbcl-package-p (package)
(let ((docstring (documentation package 't)))
(or (null docstring)
(and (stringp docstring)
(or (starts-with docstring "private")
(starts-with docstring "internal"))))))
(defun list-private-sbcl-packages ()
(remove-if-not #'private-sbcl-package-p (list-all-sbcl-packages)))
(defun list-public-sbcl-packages ()
(remove-if #'private-sbcl-package-p (list-all-sbcl-packages)))
CL-USER> (list-private-sbcl-packages)
(#<PACKAGE "SB-X86-64-ASM"> #<PACKAGE "SB-DISASSEM"> #<PACKAGE "SB-RBTREE">
#<PACKAGE "SB-VM"> #<PACKAGE "SB-REGALLOC"> #<PACKAGE "SB-PRETTY">
#<PACKAGE "SB-CLTL2"> #<PACKAGE "SB-FASL"> #<PACKAGE "SB-BIGNUM">
#<PACKAGE "SB-POSIX"> #<PACKAGE "SB-BSD-SOCKETS-INTERNAL">
#<PACKAGE "SB-LOCKLESS"> #<PACKAGE "SB-KERNEL"> #<PACKAGE "SB-DI">
#<PACKAGE "SB-ALIEN-INTERNALS"> #<PACKAGE "SB-APROF"> #<PACKAGE "SB-FORMAT">
#<PACKAGE "SB-INT"> #<PACKAGE "SB-SYS"> #<PACKAGE "SB-EVAL">
#<PACKAGE "SB-WALKER"> #<PACKAGE "SB-UNIX"> #<PACKAGE "SB-IMPL">
#<PACKAGE "SB-LOOP"> #<PACKAGE "SB-ASSEM"> #<PACKAGE "SB-C">
#<PACKAGE "SB-INTROSPECT">)
CL-USER> (list-public-sbcl-packages)
(#<PACKAGE "SB-BSD-SOCKETS"> #<PACKAGE "SB-PCL"> #<PACKAGE "SB-THREAD">
#<PACKAGE "SB-DEBUG"> #<PACKAGE "SB-PROFILE"> #<PACKAGE "SB-SEQUENCE">
#<PACKAGE "SB-MOP"> #<PACKAGE "SB-ALIEN"> #<PACKAGE "SB-GRAY">
#<PACKAGE "SB-UNICODE"> #<PACKAGE "SB-EXT">)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment