From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.devel Subject: Re: Un-deprecating oset Date: Wed, 03 Jun 2020 15:03:35 +0100 Message-ID: <874krsxn48.fsf@tcd.ie> References: <87eery1xhe.fsf@bernoul.li> <87a72d42h2.fsf@bernoul.li> <87a726tg3c.fsf@bernoul.li> <877dx1rt78.fsf@bernoul.li> <83zh9wujkx.fsf@gnu.org> <83sgfougls.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="105635"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: jonas@bernoul.li, Stefan Monnier , johnw@gnu.org, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jun 03 16:04:31 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jgU0M-000RRL-Lj for ged-emacs-devel@m.gmane-mx.org; Wed, 03 Jun 2020 16:04:30 +0200 Original-Received: from localhost ([::1]:43536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgU0L-0001hq-OM for ged-emacs-devel@m.gmane-mx.org; Wed, 03 Jun 2020 10:04:29 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgTzj-0001Bk-2w for emacs-devel@gnu.org; Wed, 03 Jun 2020 10:03:51 -0400 Original-Received: from mail-qt1-x82d.google.com ([2607:f8b0:4864:20::82d]:36055) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jgTzh-0005fp-3c for emacs-devel@gnu.org; Wed, 03 Jun 2020 10:03:50 -0400 Original-Received: by mail-qt1-x82d.google.com with SMTP id w9so2096195qtv.3 for ; Wed, 03 Jun 2020 07:03:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=lWIC6I3ZdRAgDwUrk+zgdKz9C1rjTL5jFGLSE8195Xc=; b=AnvMC4mMOsJOEw4xx8Y/9yYQ9A1Cz34LlZ0H+dzTyyg8FFlZaoYakf41D+S9IXNkEd 2Ro+AiBHN7mJghuuNCSHA1qupMA8h8SLk5Mblrm1gVVZZut9ejW5nQcsqH8V0Vd7py5i tCCf64OYRc2KcoKe/XeN1w2wM+Ok6QdxVF3ddbXIYi4gVz1yPsOKePHyIodZqfPih6JB P+5W+u+Oy9DyH2bNN5XgWueamj000GIb5RAYeWjRaTR281p8BBkIqUuD7N4FZm46s4YM i1fkDLQFEsBdSEjAZOZf6oN0MeJZd37eYio/CXOd0LKJ0vzeXgksUj5/SiwucI+KGf3j kYRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=lWIC6I3ZdRAgDwUrk+zgdKz9C1rjTL5jFGLSE8195Xc=; b=lOqx4F8clHMt7qtjDh4wLnluvkadZ5U3x4v8oWt8KMA+THC5sD5bYahsIdE3ncSTxy S2in7X7FoPYIafAuyyyIBDDga3Lk7RfKXKO4ITrJRt7WvgEmDNzNsPJTAjb1R/MkwQCd m3Fy4c6jyKUA9HWajEodhXbEh5hxc1UA//w4jFzVUf5+W9KujI0X+xOOwk0I5uWv27/V iw7XxeokILorBF/DtRrHKfKcuJyuQ7WJK8cjxmG2Wx08ATbyH0YRwYON8+WtEjwglE1b z0iZqQWDluwQkckEQpBzpvsyeXKUJvh1zRzWa+D3YWsyB3VbWf/l2OKM786gKtk/oQ2b rsVw== X-Gm-Message-State: AOAM531AxudPTG1DRtV3gfCpog6dvoiwvcNOZyWPddGuFgNdTjuL06s6 Gitcb6OBO58vS4aFvGCgMBp5Hg== X-Google-Smtp-Source: ABdhPJwkRnxv9otV61/UGtgXFKkPMX+YC1INNMOTczpBahrT683WFSwMx24G4kaZlML/R/vp9/35Ww== X-Received: by 2002:ac8:4742:: with SMTP id k2mr25383195qtp.304.1591193026233; Wed, 03 Jun 2020 07:03:46 -0700 (PDT) Original-Received: from localhost ([2a02:8084:20e2:c380:1f68:7ff5:120d:64e]) by smtp.gmail.com with ESMTPSA id m53sm2120857qtb.64.2020.06.03.07.03.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 07:03:44 -0700 (PDT) In-Reply-To: <83sgfougls.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 25 May 2020 19:25:19 +0300") Received-SPF: none client-ip=2607:f8b0:4864:20::82d; envelope-from=contovob@tcd.ie; helo=mail-qt1-x82d.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:251806 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Stefan Monnier >> Cc: Jonas Bernoulli , 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 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Fix-some-EIEIO-obsoletions.patch >From 5b6eedfee3ac95313d29dca57f56461322dd9b13 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" 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{#} 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) ;;; 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)))) ;;; 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 --=-=-=--