(defmacro define-cached-synonym
(name &optional (original (symbolicate "%" name)))
- (let ((cached-name (symbolicate "%%" name "-cached")))
+ (let ((cached-name (symbolicate "%%" name "-CACHED")))
`(progn
(defun-cached (,cached-name :hash-bits 8
:hash-function (lambda (x)
;;;; various operations on names
;;; Is NAME a legal function name?
+(declaim (inline legal-fun-name-p))
(defun legal-fun-name-p (name)
(values (valid-function-name-p name)))
+(deftype function-name () '(satisfies legal-fun-name-p))
+
;;; Signal an error unless NAME is a legal function name.
(defun legal-fun-name-or-type-error (name)
(unless (legal-fun-name-p name)
(error 'simple-type-error
:datum name
- :expected-type '(or symbol list)
+ :expected-type 'function-name
:format-control "invalid function name: ~S"
:format-arguments (list name))))
(%failed-aver ,(format nil "~A" expr))))
(defun %failed-aver (expr-as-string)
+ ;; hackish way to tell we're in a cold sbcl and output the
+ ;; message before signallign error, as it may be this is too
+ ;; early in the cold init.
+ (when (find-package "SB!C")
+ (fresh-line)
+ (write-line "failed AVER:")
+ (write-line expr-as-string)
+ (terpri))
(bug "~@<failed AVER: ~2I~_~S~:>" expr-as-string))
(defun bug (format-control &rest format-arguments)
(%failed-enforce-type ,value ',type))))
(defun %failed-enforce-type (value type)
- (error 'simple-type-error ; maybe should be TYPE-BUG, subclass of BUG?
- :value value
+ ;; maybe should be TYPE-BUG, subclass of BUG? If it is changed,
+ ;; check uses of it in user-facing code (e.g. WARN)
+ (error 'simple-type-error
+ :datum value
:expected-type type
:format-control "~@<~S ~_is not a ~_~S~:>"
:format-arguments (list value type)))