diff options
| author | Basil L. Contovounesios | 2020-06-03 17:35:59 +0100 |
|---|---|---|
| committer | Basil L. Contovounesios | 2020-06-06 17:24:00 +0100 |
| commit | 8bcc781bc762b4082cfd678b88938e3d03465d91 (patch) | |
| tree | c633ddabe6c442953e08f60eff889966d5214703 /lisp | |
| parent | acd2cb28ef63188bff31fc167ab007a051f99c17 (diff) | |
| download | emacs-8bcc781bc762b4082cfd678b88938e3d03465d91.tar.gz emacs-8bcc781bc762b4082cfd678b88938e3d03465d91.zip | |
Un-deprecate oset and oset-default
For discussion see the following threads:
https://lists.gnu.org/archive/html/emacs-devel/2020-05/msg00630.html
https://lists.gnu.org/archive/html/emacs-devel/2020-05/msg00674.html
https://lists.gnu.org/archive/html/emacs-devel/2020-06/msg00099.html
* 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
lexical-binding.
(eieio-test-13-init-methods): Simplify.
(eieio-test-33-instance-tracker): Declare IT-list as special.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/emacs-lisp/eieio-core.el | 4 | ||||
| -rw-r--r-- | lisp/emacs-lisp/eieio.el | 14 |
2 files changed, 5 insertions, 13 deletions
diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el index 1e53f30a2ae..3bc65d0d4c5 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." | |||
| 730 | (guard (not (memq name eieio--known-slot-names)))) | 730 | (guard (not (memq name eieio--known-slot-names)))) |
| 731 | (macroexp--warn-and-return | 731 | (macroexp--warn-and-return |
| 732 | (format-message "Unknown slot `%S'" name) exp 'compile-only)) | 732 | (format-message "Unknown slot `%S'" name) exp 'compile-only)) |
| 733 | (_ exp))))) | 733 | (_ exp)))) |
| 734 | (gv-setter eieio-oset)) | ||
| 734 | (cl-check-type slot symbol) | 735 | (cl-check-type slot symbol) |
| 735 | (cl-check-type obj (or eieio-object class)) | 736 | (cl-check-type obj (or eieio-object class)) |
| 736 | (let* ((class (cond ((symbolp obj) | 737 | (let* ((class (cond ((symbolp obj) |
| @@ -755,6 +756,7 @@ Argument FN is the function calling this verifier." | |||
| 755 | (defun eieio-oref-default (obj slot) | 756 | (defun eieio-oref-default (obj slot) |
| 756 | "Do the work for the macro `oref-default' with similar parameters. | 757 | "Do the work for the macro `oref-default' with similar parameters. |
| 757 | Fills in OBJ's SLOT with its default value." | 758 | Fills in OBJ's SLOT with its default value." |
| 759 | (declare (gv-setter eieio-oset-default)) | ||
| 758 | (cl-check-type obj (or eieio-object class)) | 760 | (cl-check-type obj (or eieio-object class)) |
| 759 | (cl-check-type slot symbol) | 761 | (cl-check-type slot symbol) |
| 760 | (let* ((cl (cond ((symbolp obj) (cl--find-class obj)) | 762 | (let* ((cl (cond ((symbolp obj) (cl--find-class obj)) |
diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el index ee5dd2cccdb..b75410ee220 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." | |||
| 513 | "Set the value in OBJ for slot SLOT to VALUE. | 513 | "Set the value in OBJ for slot SLOT to VALUE. |
| 514 | SLOT is the slot name as specified in `defclass' or the tag created | 514 | SLOT is the slot name as specified in `defclass' or the tag created |
| 515 | with in the :initarg slot. VALUE can be any Lisp object." | 515 | with in the :initarg slot. VALUE can be any Lisp object." |
| 516 | (declare (obsolete "use (setf (oref ..) ..) instead" "28.1") | 516 | (declare (debug (form symbolp form))) |
| 517 | (debug (form symbolp form))) | ||
| 518 | `(eieio-oset ,obj (quote ,slot) ,value)) | 517 | `(eieio-oset ,obj (quote ,slot) ,value)) |
| 519 | 518 | ||
| 520 | (defmacro oset-default (class slot value) | 519 | (defmacro oset-default (class slot value) |
| @@ -522,8 +521,7 @@ with in the :initarg slot. VALUE can be any Lisp object." | |||
| 522 | The default value is usually set with the :initform tag during class | 521 | The default value is usually set with the :initform tag during class |
| 523 | creation. This allows users to change the default behavior of classes | 522 | creation. This allows users to change the default behavior of classes |
| 524 | after they are created." | 523 | after they are created." |
| 525 | (declare (obsolete "use (setf (oref-default ..) ..) instead" "28.1") | 524 | (declare (debug (form symbolp form))) |
| 526 | (debug (form symbolp form))) | ||
| 527 | `(eieio-oset-default ,class (quote ,slot) ,value)) | 525 | `(eieio-oset-default ,class (quote ,slot) ,value)) |
| 528 | 526 | ||
| 529 | ;;; CLOS queries into classes and slots | 527 | ;;; CLOS queries into classes and slots |
| @@ -647,14 +645,6 @@ If SLOT is unbound, do nothing." | |||
| 647 | nil | 645 | nil |
| 648 | (eieio-oset object slot (delete item (eieio-oref object slot))))) | 646 | (eieio-oset object slot (delete item (eieio-oref object slot))))) |
| 649 | 647 | ||
| 650 | ;;; Here are some CLOS items that need the CL package | ||
| 651 | ;; | ||
| 652 | |||
| 653 | ;; FIXME: Shouldn't this be a more complex gv-expander which extracts the | ||
| 654 | ;; common code between oref and oset, so as to reduce the redundant work done | ||
| 655 | ;; in (push foo (oref bar baz)), like we do for the `nth' expander? | ||
| 656 | (gv-define-simple-setter eieio-oref eieio-oset) | ||
| 657 | |||
| 658 | 648 | ||
| 659 | ;;; | 649 | ;;; |
| 660 | ;; We want all objects created by EIEIO to have some default set of | 650 | ;; We want all objects created by EIEIO to have some default set of |