* lisp/emacs-lisp/eieio-base.el (make-instance) <eieio-named>:
Really skip backward compatibility when `eieio-backward-compatibility`
is nil and emit message if it's `warn`.
(eieio-persistent-make-instance): Warn when an obsolete name is used.
* lisp/emacs-lisp/eieio-core.el (eieio-backward-compatibility):
Change default to `warn`.
(eieio-defclass-internal): Warn when the *-list-p function is called
(eieio--slot-name-index): Warn when a initarg is used to access a slot.
* lisp/emacs-lisp/eieio.el (defclass): Warn when a class-slot is
accessed via the obsolete method.
(make-instance, clone) <eieio-default-superclass>: Really skip backward
compatibility when `eieio-backward-compatibility` is nil and emit
message if it's `warn`.
(cherry picked from commit
ae1d01328f260f1a9891280c96139494629a83e8)
nobj))
(cl-defmethod make-instance ((class (subclass eieio-named)) &rest args)
- (if (not (stringp (car args)))
+ (if (not (and eieio-backward-compatibility args
+ (let ((x (car args))) (or (stringp x) (null x)))))
(cl-call-next-method)
- (funcall (if eieio-backward-compatibility #'ignore #'message)
- "Obsolete: name passed without :object-name to %S constructor"
- class)
+ (when (eq eieio-backward-compatibility 'warn)
+ (message "Obsolete: name passed without :object-name to %S constructor"
+ class))
(apply #'cl-call-next-method class :object-name args)))
;;; eieio-persistent
(object-of-class-p newobj 'eieio-named)
(not (oref newobj object-name))
name)
+ (when (eq eieio-backward-compatibility 'warn)
+ (message "Obsolete name slot initialized for %S" newobj))
(oset newobj object-name name))
newobj))))
(defvar eieio-optimize-primary-methods-flag t
"Non-nil means to optimize the method dispatch on primary methods.")
-(defvar eieio-backward-compatibility t
+(defvar eieio-backward-compatibility 'warn
"If nil, drop support for some behaviors of older versions of EIEIO.
Currently under control of this var:
- Define every class as a var whose value is the class symbol.
- Define <class>-child-p and <class>-list-p predicates.
-- Allow object names in constructors.")
+- Allow object names in constructors.
+When `warn', also emit warnings at run-time when code uses those
+deprecated features.")
(define-obsolete-variable-alias 'eieio-unbound 'eieio--unbound "28.1")
(defvar eieio--unbound (make-symbol "eieio--unbound")
(internal--format-docstring-line
"Test OBJ to see if it a list of objects which are a child of type `%s'."
cname))
+ (when (eq eieio-backward-compatibility 'warn)
+ (message "Use of obsolete function %S" csym))
(when (listp obj)
(let ((ans t)) ;; nil is valid
;; Loop over all the elements of the input list, test
(let* ((fsi (gethash slot (cl--class-index-table class))))
(if (integerp fsi)
fsi
- (let ((fn (eieio--initarg-to-attribute class slot)))
- (if fn
+ (when eieio-backward-compatibility
+ (let ((fn (eieio--initarg-to-attribute class slot)))
+ (when fn
+ (when (eq eieio-backward-compatibility 'warn)
+ (message "Accessing slot `%S' via obsolete initarg name `%S'"
+ fn slot))
;; Accessing a slot via its :initarg is accepted by EIEIO
;; (but not CLOS) but is a bad idea (for one: it's slower).
- (eieio--slot-name-index class fn)
- nil)))))
+ (eieio--slot-name-index class fn)))))))
(defun eieio--class-slot-name-index (class slot)
"In CLASS find the index of the named SLOT.
"Retrieve the class slot `%S' from a class `%S'."
sname name)
"\nThis method is obsolete.")
+ (when (eq eieio-backward-compatibility 'warn)
+ (message "Use of obsolete method %S on %S"
+ ',acces '(subclass ,name)))
(if (slot-boundp this ',sname)
(eieio-oref-default this ',sname)))
accessors)))
calls `initialize-instance' on that object."
(let* ((new-object (copy-sequence (eieio--class-default-object-cache
(eieio--class-object class)))))
- (if (and slots
- (let ((x (car slots)))
- (or (stringp x) (null x))))
- (funcall (if eieio-backward-compatibility #'ignore #'message)
- "Obsolete name argument %S passed to %S constructor"
- (pop slots) class))
+ (when (and eieio-backward-compatibility slots
+ (let ((x (car slots)))
+ (or (stringp x) (null x))))
+ (let ((name (pop slots)))
+ (when (eq eieio-backward-compatibility 'warn)
+ (message "Obsolete name argument %S passed to %S constructor"
+ name class))))
;; Call the initialize method on the new object with the slots
;; that were passed down to us.
(initialize-instance new-object slots)
(cl-defmethod clone ((obj eieio-default-superclass) &rest params)
"Make a copy of OBJ, and then apply PARAMS."
(let ((nobj (copy-sequence obj)))
- (if (stringp (car params))
- (funcall (if eieio-backward-compatibility #'ignore #'message)
- "Obsolete name argument %S passed to clone" (pop params)))
+ (when (and eieio-backward-compatibility params
+ (let ((x (car params)))
+ (or (stringp x) (null x))))
+ (let ((name (pop params)))
+ (when (eq eieio-backward-compatibility 'warn)
+ (message "Obsolete name argument %S passed to clone" name))))
(if params (shared-initialize nobj params))
nobj))