Skip to content
This repository was archived by the owner on Aug 13, 2025. It is now read-only.

Commit a1fa844

Browse files
Remove with-creating-find-package
PiperOrigin-RevId: 609852537
1 parent 5a9d9e7 commit a1fa844

1 file changed

Lines changed: 21 additions & 22 deletions

File tree

main.lisp

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -589,30 +589,29 @@ If LISP_MAIN is NIL or T it will call top-level REPL as well."
589589
"Return a symbol feature derived from a FEATURE string or symbol.
590590
591591
By default the string is read into the KEYWORD package.
592-
If the feature string is package prefixed, the package
593-
is instantiated unless already provided.
594-
595-
If the feature parses as anything other than a symbol,
596-
it will signal an error."
597-
(typecase feature
592+
If the feature string is package prefixed, the package is made
593+
with a default :USE list of (\"CL\") unless it already exists."
594+
(etypecase feature
598595
(symbol feature)
599596
(string
600-
(multiple-value-bind (value error)
601-
(ignore-errors
602-
(let ((*package* (find-package "KEYWORD")))
603-
(with-creating-find-package ()
604-
(values (read-from-string feature)))))
605-
(cond ((and (symbolp value) value))
606-
(error
607-
(bazel.log:fatal
608-
"Could not parse ~S as a feature due to~% ~S: ~A~%"
609-
feature (type-of error) error)
610-
nil)
611-
(t
612-
(bazel.log:fatal "Cannot parse ~S as a feature." feature)
613-
nil))))
614-
(t
615-
(bazel.log:fatal "~S is not a feature." feature))))
597+
;; Like the ~/ format directive, it makes no difference whether the feature
598+
;; is spelled using 1 colon or 2; and while #\\ and #\| escapes are not
599+
;; prohibited, they have ordinary character syntax.
600+
(let* ((string (string-upcase (string-trim '(#\sp) feature)))
601+
(colon (position #\: string))
602+
(pkgname (subseq string 0 colon))
603+
(colon2 (and colon
604+
(eql (if (< colon (1- (length string))) (char string (1+ colon)))
605+
#\:)
606+
(1+ colon)))
607+
(sym (subseq string (1+ (or colon2 colon -1)))))
608+
(if (or (position #\: sym) (= (length sym) 0))
609+
(bazel.log:fatal "~S is not a feature designator~%" feature)
610+
(values (intern sym
611+
(cond ((or (not colon) (string= pkgname ""))
612+
(find-package "KEYWORD"))
613+
((find-package pkgname))
614+
(t (make-package pkgname :use '("CL")))))))))))
616615

617616
(defun add-feature (feature)
618617
"Add a single string FEATURE to *features*."

0 commit comments

Comments
 (0)