From: "Basil L. Contovounesios" <contovob@tcd.ie>
To: Eli Zaretskii <eliz@gnu.org>
Cc: jonas@bernoul.li, Stefan Monnier <monnier@iro.umontreal.ca>,
johnw@gnu.org, emacs-devel@gnu.org
Subject: Re: Un-deprecating oset
Date: Wed, 03 Jun 2020 15:03:35 +0100 [thread overview]
Message-ID: <874krsxn48.fsf@tcd.ie> (raw)
In-Reply-To: <83sgfougls.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 25 May 2020 19:25:19 +0300")
[-- Attachment #1: Type: text/plain, Size: 1486 bytes --]
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Stefan Monnier <monnier@iro.umontreal.ca>
>> Cc: Jonas Bernoulli <jonas@bernoul.li>, johnw@gnu.org, emacs-devel@gnu.org
>> Date: Mon, 25 May 2020 12:06:54 -0400
>>
>> > I tend to think it should be un-deprecated.
>>
>> Interesting. I thought the whole CL -> CL-lib change was because we
>> didn't want to have in Emacs core libraries that stomp on the namespace
>> like that (funnily enough most of EIEIO's global names come straight
>> from Common-Lisp, oref/oset being the main exception ;-)
>>
>> So does that also mean that EIEIO's names are now accepted into the
>> core namespace? It seems rather odd that `defclass` is allowed into the
>> core namespace while `defstruct` had to be relegated to `cl-defstruct`.
>
> I didn't mean we should stop cleaning up the global namespace, just
> that this case could be one of the few exclusions.
How's the attached patch for un-deprecating oset and oset-default?
Political rationale:
0. Most voiced opinions have been in favour of keeping oset.
1. Though most are in favour of cleaning EIEIO's namespace,
deprecating only oset causes hassle without sufficient gain.
Technical rationale:
2. oset is widely used.
3. oref-default is not yet setf-able, so we'd have to recommend using
eieio-oset-default in place of oset-default, which has been described
as probably undesirable.
WDYT?
Should the changes to the manuals go to emacs-27 instead of master?
Thanks,
--
Basil
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-some-EIEIO-obsoletions.patch --]
[-- Type: text/x-diff, Size: 8834 bytes --]
From 5b6eedfee3ac95313d29dca57f56461322dd9b13 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Wed, 3 Jun 2020 14:18:19 +0100
Subject: [PATCH] Fix some EIEIO obsoletions
The deprecation of oset and oset-default was discussed in 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
* doc/misc/ede.texi (ede-generic-project): Tidy up example.
* doc/misc/eieio.texi (Accessing Slots): Document oref,
oref-default, and slot-value as generalized variables, and
set-slot-value as obsolete. Consistently document getters before
setters.
(Predicates): Mention cl-print-object in place of the obsolete
object-print.
(Introspection): Document eieio-class-slots in place of the obsolete
object-slots.
* lisp/emacs-lisp/eieio.el: Un-deprecate oset and oset-default.
Make oref-default setf-able.
* etc/NEWS: Announce this change.
* 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.
---
doc/misc/ede.texi | 10 ++--
doc/misc/eieio.texi | 49 +++++++++++++------
etc/NEWS | 7 ++-
lisp/emacs-lisp/eieio.el | 7 ++-
.../emacs-lisp/eieio-tests/eieio-tests.el | 5 +-
5 files changed, 49 insertions(+), 29 deletions(-)
diff --git a/doc/misc/ede.texi b/doc/misc/ede.texi
index 584b0d7ee5..412176986c 100644
--- a/doc/misc/ede.texi
+++ b/doc/misc/ede.texi
@@ -955,18 +955,16 @@ ede-generic-project
;;; MAKEFILE
(defclass ede-generic-makefile-project (ede-generic-project)
- ((buildfile :initform "Makefile")
- )
+ ((buildfile :initform "Makefile"))
"Generic Project for makefiles.")
(defmethod ede-generic-setup-configuration ((proj ede-generic-makefile-project) config)
- "Setup a configuration for Make."
+ "Set up a configuration for Make."
(oset config build-command "make -k")
- (oset config debug-command "gdb ")
- )
+ (oset config debug-command "gdb "))
(ede-generic-new-autoloader "generic-makefile" "Make"
- "Makefile" 'ede-generic-makefile-project)
+ "Makefile" 'ede-generic-makefile-project)
@end example
This example project will detect any directory with the file
diff --git a/doc/misc/eieio.texi b/doc/misc/eieio.texi
index 3943c544c7..06093f7263 100644
--- a/doc/misc/eieio.texi
+++ b/doc/misc/eieio.texi
@@ -698,6 +698,27 @@ Accessing Slots
referencing vectors (@pxref{Vectors,,,elisp,GNU Emacs Lisp Reference
Manual}).
+@defmac oref obj slot
+@anchor{oref}
+This macro retrieves the value stored in @var{obj} in the slot named
+by @var{slot}. @var{slot} is the name of the slot when created by
+@dfn{defclass}.
+
+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
+@anchor{oref-default}
+This macro returns the value of the class-allocated @var{slot} from
+@var{class}.
+
+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 @@ Accessing Slots
@end example
@end defmac
-@defmac oref obj slot
-@anchor{oref}
-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
-@anchor{oref-default}
-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.
@@ -734,14 +744,21 @@ Accessing Slots
@anchor{slot-value}
This function retrieves the value of @var{slot} from @var{object}.
Unlike @code{oref}, the symbol for @var{slot} must be quoted.
+
+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 defun
@defun set-slot-value object slot value
@anchor{set-slot-value}
-This is not a CLOS function, but is the setter for @code{slot-value}
-used by the @code{setf} macro. This
-function sets the value of @var{slot} from @var{object}. Unlike
+This function sets the value of @var{slot} from @var{object}. Unlike
@code{oset}, the symbol for @var{slot} must be quoted.
+
+This is not a CLOS function, but is the obsolete setter for
+@code{slot-value} used by the @code{setf} macro. It is therefore
+recommended to use @code{(setf (slot-value @var{object} @var{slot})
+@var{value})} instead.
@end defun
@defun slot-makeunbound object slot
@@ -1061,7 +1078,7 @@ Predicates
Return a string of the form @samp{#<object-class myobjname>} for @var{obj}.
This should look like Lisp symbols from other parts of Emacs such as
buffers and processes, and is shorter and cleaner than printing the
-object's record. It is more useful to use @code{object-print} to get
+object's record. It is more useful to use @code{cl-print-object} to get
and object's print form, as this allows the object to add extra display
information into the symbol.
@end defun
@@ -1217,7 +1234,7 @@ Introspection
some functions have been provided. None of these functions are a part
of CLOS.
-@defun object-slots obj
+@defun eieio-class-slots obj
Return the list of public slots for @var{obj}.
@end defun
diff --git a/etc/NEWS b/etc/NEWS
index ed4722b27f..27e511047e 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.
+** EIEIO
+
++++
+*** 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.el b/lisp/emacs-lisp/eieio.el
index ee5dd2cccd..73573a80eb 100644
--- a/lisp/emacs-lisp/eieio.el
+++ b/lisp/emacs-lisp/eieio.el
@@ -513,8 +513,7 @@ oset
"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 @@ oset-default
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
@@ -654,6 +652,7 @@ object-remove-from-list
;; 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)
+(gv-define-simple-setter eieio-oref-default eieio-oset-default)
\f
;;;
diff --git a/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el b/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el
index 34c20b2003..21adc91e55 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 @@ eieio-test-13-init-methods
(oset a test-tag 1))
(let ((ca (class-a)))
- (should-not (/= (oref ca test-tag) 2))))
+ (should (= (oref ca test-tag) 2))))
\f
;;; Perform slot testing
@@ -852,6 +852,7 @@ IT
"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
--
2.26.2
next prev parent reply other threads:[~2020-06-03 14:03 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-05 10:34 Un-deprecating oset Jonas Bernoulli
2020-05-05 10:48 ` Philippe Vaucher
2020-05-05 11:11 ` Basil L. Contovounesios
2020-05-05 14:50 ` Stefan Monnier
2020-05-12 15:06 ` Jonas Bernoulli
2020-05-12 16:49 ` Philippe Vaucher
2020-05-12 21:47 ` Adam Porter
2020-05-13 13:04 ` Philipp Stephani
2020-05-14 7:50 ` Juanma Barranquero
2020-05-14 12:13 ` Basil L. Contovounesios
2020-05-14 12:31 ` Juanma Barranquero
2020-05-17 21:19 ` Jonas Bernoulli
2020-05-24 20:09 ` Jonas Bernoulli
2020-05-25 15:21 ` Eli Zaretskii
2020-05-25 16:06 ` Stefan Monnier
2020-05-25 16:25 ` Eli Zaretskii
2020-06-03 14:03 ` Basil L. Contovounesios [this message]
2020-06-03 17:03 ` Basil L. Contovounesios
2020-06-06 7:38 ` Eli Zaretskii
2020-06-06 16:43 ` Basil L. Contovounesios
2020-06-08 12:42 ` Jonas Bernoulli
2020-05-25 17:27 ` Jonas Bernoulli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874krsxn48.fsf@tcd.ie \
--to=contovob@tcd.ie \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=johnw@gnu.org \
--cc=jonas@bernoul.li \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).