;; Deprecating stuff
"DEFINE-DEPRECATED-FUNCTION"
+ "DEFINE-DEPRECATED-VARIABLE"
+ "DEPRECATED-VARIABLE"
+ "CHECK-DEPRECATED-VARIABLE"
"EARLY-DEPRECATION-WARNING"
"LATE-DEPRECATION-WARNING"
"FINAL-DEPRECATION-WARNING"
(setf (compiler-macro-function ',name)
(deprecation-compiler-macro ,state ,since ',name ',replacements)))))
+(defun check-deprecated-variable (name)
+ (let ((info (info :variable :deprecated name)))
+ (when info
+ (deprecation-warning (car info) (cdr info) name nil))))
+
+(defmacro define-deprecated-variable (state since name &key (value nil valuep) replacement)
+ `(progn
+ (setf (info :variable :deprecated ',name) (cons ,state ,since))
+ ,@(when (member state '(:early :late))
+ `((defvar ,name ,@(when valuep (list value))
+ ,(let ((*package* (find-package :keyword)))
+ (format nil
+ "~@<~S has been deprecated as of SBCL ~A~@[, use ~S instead~].~:>"
+ name since replacement)))))))
+
;;; Anaphoric macros
(defmacro awhen (test &body body)
`(let ((it ,test))
(declare (optimize (safety 1)))
(symbol-value symbol))
+#-sb-xc-host
+(define-compiler-macro symbol-value (&whole form symbol &environment env)
+ (when (sb!xc:constantp symbol env)
+ (let ((name (constant-form-value symbol env)))
+ (when (symbolp name)
+ (check-deprecated-variable name))))
+ form)
+
(defun boundp (symbol)
#!+sb-doc
"Return non-NIL if SYMBOL is bound to a value."
;; processing our own code, though.
#+sb-xc-host
(warn "reading an ignored variable: ~S" name)))
+ (when (global-var-p var)
+ (check-deprecated-variable name))
(reference-leaf start next result var name))
(cons
(aver (eq (car var) 'macro))