[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 8bcc781: Un-deprecate oset and oset-default

From: Basil L. Contovounesios
Subject: master 8bcc781: Un-deprecate oset and oset-default
Date: Sat, 6 Jun 2020 12:40:06 -0400 (EDT)

branch: master
commit 8bcc781bc762b4082cfd678b88938e3d03465d91
Author: Basil L. Contovounesios <contovob@tcd.ie>
Commit: Basil L. Contovounesios <contovob@tcd.ie>

    Un-deprecate oset and oset-default
    For discussion see the following threads:
    * lisp/emacs-lisp/eieio.el (oset, oset-default): Un-deprecate.
    * lisp/emacs-lisp/eieio-core.el (eieio-oref): Declare gv-setter here
    instead of in lisp/emacs-lisp/eieio.el.  Suggested by
    Stefan Monnier <monnier@iro.umontreal.ca>.
    (eieio-oref-default): Add gv-setter declaration.
    * etc/NEWS: Announce these changes.
    * doc/misc/eieio.texi (Accessing Slots): Document oref and
    oref-default as generalized variables.  Consistently document
    getters before setters.
    * test/lisp/emacs-lisp/eieio-tests/eieio-tests.el: Use
    (eieio-test-13-init-methods): Simplify.
    (eieio-test-33-instance-tracker): Declare IT-list as special.
 doc/misc/eieio.texi                             | 32 ++++++++++++++++---------
 etc/NEWS                                        |  7 +++++-
 lisp/emacs-lisp/eieio-core.el                   |  4 +++-
 lisp/emacs-lisp/eieio.el                        | 14 ++---------
 test/lisp/emacs-lisp/eieio-tests/eieio-tests.el |  5 ++--
 5 files changed, 35 insertions(+), 27 deletions(-)

diff --git a/doc/misc/eieio.texi b/doc/misc/eieio.texi
index 3943c54..6e7d438 100644
--- a/doc/misc/eieio.texi
+++ b/doc/misc/eieio.texi
@@ -698,6 +698,27 @@ and argument-order conventions are similar to those used 
 referencing vectors (@pxref{Vectors,,,elisp,GNU Emacs Lisp Reference
+@defmac oref obj slot
+This macro retrieves the value stored in @var{obj} in the named
+@var{slot}.  Slot names are determined by @code{defclass} which
+creates the slot.
+This is a generalized variable that can be used with @code{setf} to
+modify the value stored in @var{slot}.  @xref{Generalized
+Variables,,,elisp,GNU Emacs Lisp Reference Manual}.
+@end defmac
+@defmac oref-default class slot
+This macro returns the value of the class-allocated @var{slot} from
+This is a generalized variable that can be used with @code{setf} to
+modify the value stored in @var{slot}.  @xref{Generalized
+Variables,,,elisp,GNU Emacs Lisp Reference Manual}.
+@end defmac
 @defmac oset object slot value
 This macro sets the value behind @var{slot} to @var{value} in
 @var{object}.  It returns @var{value}.
@@ -716,17 +737,6 @@ changed, this can be arranged by simply executing this bit 
of code:
 @end example
 @end defmac
-@defmac oref obj slot
-Retrieve the value stored in @var{obj} in the slot named by @var{slot}.
-Slot is the name of the slot when created by @dfn{defclass}.
-@end defmac
-@defmac oref-default class slot
-Get the value of the class-allocated @var{slot} from @var{class}.
-@end defmac
 The following accessors are defined by CLOS to reference or modify
 slot values, and use the previously mentioned set/ref routines.
diff --git a/etc/NEWS b/etc/NEWS
index ed4722b..27e5110 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -112,7 +112,12 @@ setting the variable 'auto-save-visited-mode' 
buffer-locally to nil.
 ** New bindings in occur-mode, 'next-error-no-select' bound to 'n' and
 'previous-error-no-select' bound to 'p'.
-** EIEIO: 'oset' and 'oset-default' are declared obsolete.
+*** The macro 'oref-default' can now be used with 'setf'.
+It is now defined as a generalized variable that can be used with
+'setf' to modify the value stored in a given class slot.
 ** New minor mode 'cl-font-lock-built-in-mode' for `lisp-mode'.
 The mode provides refined highlighting of built-in functions, types,
diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el
index 1e53f30..3bc65d0 100644
--- a/lisp/emacs-lisp/eieio-core.el
+++ b/lisp/emacs-lisp/eieio-core.el
@@ -730,7 +730,8 @@ Argument FN is the function calling this verifier."
                       (guard (not (memq name eieio--known-slot-names))))
                   (format-message "Unknown slot `%S'" name) exp 'compile-only))
-                (_ exp)))))
+                (_ exp))))
+           (gv-setter eieio-oset))
   (cl-check-type slot symbol)
   (cl-check-type obj (or eieio-object class))
   (let* ((class (cond ((symbolp obj)
@@ -755,6 +756,7 @@ Argument FN is the function calling this verifier."
 (defun eieio-oref-default (obj slot)
   "Do the work for the macro `oref-default' with similar parameters.
 Fills in OBJ's SLOT with its default value."
+  (declare (gv-setter eieio-oset-default))
   (cl-check-type obj (or eieio-object class))
   (cl-check-type slot symbol)
   (let* ((cl (cond ((symbolp obj) (cl--find-class obj))
diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el
index ee5dd2c..b75410e 100644
--- a/lisp/emacs-lisp/eieio.el
+++ b/lisp/emacs-lisp/eieio.el
@@ -513,8 +513,7 @@ The CLOS function `class-direct-subclasses' is aliased to 
this function."
   "Set the value in OBJ for slot SLOT to VALUE.
 SLOT is the slot name as specified in `defclass' or the tag created
 with in the :initarg slot.  VALUE can be any Lisp object."
-  (declare (obsolete "use (setf (oref ..) ..) instead" "28.1")
-           (debug (form symbolp form)))
+  (declare (debug (form symbolp form)))
   `(eieio-oset ,obj (quote ,slot) ,value))
 (defmacro oset-default (class slot value)
@@ -522,8 +521,7 @@ with in the :initarg slot.  VALUE can be any Lisp object."
 The default value is usually set with the :initform tag during class
 creation.  This allows users to change the default behavior of classes
 after they are created."
-  (declare (obsolete "use (setf (oref-default ..) ..) instead" "28.1")
-           (debug (form symbolp form)))
+  (declare (debug (form symbolp form)))
   `(eieio-oset-default ,class (quote ,slot) ,value))
 ;;; CLOS queries into classes and slots
@@ -647,14 +645,6 @@ If SLOT is unbound, do nothing."
     (eieio-oset object slot (delete item (eieio-oref object slot)))))
-;;; Here are some CLOS items that need the CL package
-;; FIXME: Shouldn't this be a more complex gv-expander which extracts the
-;; common code between oref and oset, so as to reduce the redundant work done
-;; in (push foo (oref bar baz)), like we do for the `nth' expander?
-(gv-define-simple-setter eieio-oref eieio-oset)
 ;; We want all objects created by EIEIO to have some default set of
diff --git a/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el 
index 34c20b2..21adc91 100644
--- a/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el
+++ b/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el
@@ -1,4 +1,4 @@
-;;; eieio-tests.el -- eieio tests routines
+;;; eieio-tests.el -- eieio test routines -*- lexical-binding: t -*-
 ;; Copyright (C) 1999-2003, 2005-2010, 2012-2020 Free Software
 ;; Foundation, Inc.
@@ -356,7 +356,7 @@ METHOD is the method that was attempting to be called."
     (oset a test-tag 1))
   (let ((ca (class-a)))
-    (should-not (/=  (oref ca test-tag) 2))))
+    (should (= (oref ca test-tag) 2))))
 ;;; Perform slot testing
@@ -852,6 +852,7 @@ Subclasses to override slot attributes.")
   "Instance Tracker test object.")
 (ert-deftest eieio-test-33-instance-tracker ()
+  (defvar IT-list)
   (let (IT-list IT1)
     (should (setq IT1 (IT)))
     ;; The instance tracker must find this

reply via email to

[Prev in Thread] Current Thread [Next in Thread]