Docstring typo
[alexandria.git] / symbols.lisp
bloba6baa2e6cef976d654a766dce06bd8e6022ef24c
1 (in-package :alexandria)
3 (defun ensure-symbol (name &optional (package *package*))
4 "Returns a symbol with name designated by NAME, accessible in package
5 designated by PACKAGE. If symbol is not already accessible in PACKAGE, it is
6 interned there.
8 Example: (ENSURE-SYMBOL :CONS :CL) => CL:CONS"
9 (let ((name (string name)))
10 (values (or (find-symbol name package)
11 (intern name package)))))
13 (defun make-formatted-symbol (package name)
14 (case package
15 ((nil)
16 (make-symbol name))
17 ((t)
18 (intern name))
20 (intern name package))))
22 (declaim (inline format-symbol))
23 (defun format-symbol (package control &rest arguments)
24 "Constructs a string by applying ARGUMENTS to CONTROL as if by FORMAT, and
25 then creates a symbol named by that string. If PACKAGE is NIL, returns an
26 uninterned symbol, if package is T, returns a symbol interned in the current
27 package, and otherwise returns a symbol interned in the package designated by
28 PACKAGE."
29 (values (make-formatted-symbol package (apply #'format nil control arguments))))
31 (defun make-keyword (name)
32 "Interns the string designated by NAME in the KEYWORD package."
33 (intern (string name) :keyword))
35 (defun make-gensym-list (length &optional x)
36 "Returns a list of LENGTH gensyms, each generated with a call to
37 GENSYM using (if provided) as the argument."
38 (loop repeat length
39 collect (gensym x)))