Skip to main content

find-all-symbols

find-all-symbols Function

Syntax:

find-all-symbols string → symbols

Arguments and Values:

string—a string designator .

symbols—a list of symbols.

Description:

find-all-symbols searches every registered package for symbols that have a name that is the same (under string=) as string. A list of all such symbols is returned. Whether or how the list is ordered is implementation-dependent.

Examples:

(find-all-symbols ’car) 
(CAR)
<i><sup>or</sup>→</i> (CAR VEHICLES:CAR)
<i><sup>or</sup>→</i> (VEHICLES:CAR CAR)
(intern "CAR" (make-package ’temp :use nil)) → TEMP::CAR, NIL
(find-all-symbols ’car)
(TEMP::CAR CAR)
<i><sup>or</sup>→</i> (CAR TEMP::CAR)
<i><sup>or</sup>→</i> (TEMP::CAR CAR VEHICLES:CAR)
<i><sup>or</sup>→</i> (CAR TEMP::CAR VEHICLES:CAR)

See Also:

find-symbol

Expanded Reference: find-all-symbols

Basic Usage: Finding Symbols Across All Packages

find-all-symbols searches every registered package for symbols with the given name. It returns a list of all such symbols.

;; CAR exists in COMMON-LISP and is inherited by many packages,
;; but find-all-symbols returns each distinct symbol only once
(member 'car (find-all-symbols "CAR"))
;; => (CAR ...)

Finding a Symbol That Exists in Multiple Packages

(defpackage "FAS-A" (:use) (:export "SHARED"))
(defpackage "FAS-B" (:use) (:export "SHARED"))

;; These are two distinct symbols with the same name
(let ((results (find-all-symbols "SHARED")))
(>= (length results) 2))
=> T

Using a Symbol as the Argument

When a symbol is passed, its name string is used for the search.

(let ((results (find-all-symbols 'car)))
(member (find-symbol "CAR" "COMMON-LISP") results))
;; => (CAR ...)

Symbols in Bare Packages Are Also Found

(make-package "FAS-HIDDEN" :use '())
(intern "UNIQUE-FAS-SYM" "FAS-HIDDEN")

(find-all-symbols "UNIQUE-FAS-SYM")
;; => (FAS-HIDDEN::UNIQUE-FAS-SYM)

The Order of Results is Implementation-Dependent

;; The returned list may be in any order
(let ((results (find-all-symbols "CAR")))
(every #'symbolp results))
=> T