From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Vitalie Spinu Newsgroups: gmane.emacs.bugs Subject: bug#34840: [PATCH] Cloning of eieio-instance-inheritor should not initialize slots Date: Wed, 13 Mar 2019 13:40:29 +0100 Message-ID: <878sxjgd6q.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="47517"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: 34840@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Mar 13 13:46:57 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h43Hc-000CIC-PY for geb-bug-gnu-emacs@m.gmane.org; Wed, 13 Mar 2019 13:46:57 +0100 Original-Received: from localhost ([127.0.0.1]:44009 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h43Hb-00062J-OP for geb-bug-gnu-emacs@m.gmane.org; Wed, 13 Mar 2019 08:46:55 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:33315) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h43By-0001Mx-Ke for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2019 08:41:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h43Bx-0005MV-GO for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2019 08:41:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55843) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h43Bv-0005Lg-WC for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2019 08:41:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h43Bv-0007G0-Ox for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2019 08:41:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Vitalie Spinu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Mar 2019 12:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 34840 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.155248084927867 (code B ref -1); Wed, 13 Mar 2019 12:41:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 13 Mar 2019 12:40:49 +0000 Original-Received: from localhost ([127.0.0.1]:41154 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h43Bg-0007FP-Nd for submit@debbugs.gnu.org; Wed, 13 Mar 2019 08:40:48 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:47012) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h43Bf-0007FD-78 for submit@debbugs.gnu.org; Wed, 13 Mar 2019 08:40:47 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:54487) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h43BZ-00059J-21 for submit@debbugs.gnu.org; Wed, 13 Mar 2019 08:40:41 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:33141) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h43BY-00016h-5h for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2019 08:40:40 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h43BW-000586-QQ for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2019 08:40:39 -0400 Original-Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]:34985) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h43BT-000536-6z for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2019 08:40:38 -0400 Original-Received: by mail-ed1-x52f.google.com with SMTP id d6so796309eds.2 for ; Wed, 13 Mar 2019 05:40:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:user-agent:mime-version; bh=0iVcMH3BQ36araZTL0v8chrpQ1VOa9XAkE36BQW+pMs=; b=agQzVc+36uA5NqasRT6m0pe8np3MC0Sp0EhmuislInptcl81hwkMD3YZ1sWXnHxhte Ce0TBa3en8Xalps5iCTy6kwmjnIEXUfQR+yeebG4ubEO2ZLPLnTK5NP8537NVtHDlmQ5 +Ty/RQeHm6mNZ4VE4rRl+DOupDlEqgu3jo50OUZkEthjabykLT/TevzGTFdCIthUAoEx mxfBf7iR/epuTQAI+NNBaQRFNWp7teAaSE51GpafTqDI0PpRqRPwoMUR2ANfRKOzuQz8 UpB6FUNIvhs5Z/wWWhWJJNAsc+ICigHby6i2IElfXsNBAYzFyxNkWEB3akxxkSDLPk47 uR5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version; bh=0iVcMH3BQ36araZTL0v8chrpQ1VOa9XAkE36BQW+pMs=; b=q3UjLyKE8As+NJ/Bj9QIf5epi50gBHiohtVgc9LV1yAoMOwadx7dXskRWcavpMpMDW qC91k8TBMa9RVQ+m8s+AF+2q/zARVlGIwvXe/xeP5BztlcgXPizgh8drASkxi5WQJJdv 9r9+pYEEVeqHESfurp8yYgLS6pkAv4vlXAPrUAFEfHKtJPOzQImLKZxrfQLMZAp2Zsz1 oLGkli3CXQNajyXR59jKJQ1C0sPGtOvFZOR3SQb3fRLdV+WMat5iKU2p3a6ZZZjrOvS7 VHun8e1BzCtJIXic78mPDNHSViyMkMqVTeh8/uUtvIlsny8iyTxd/0jHOGlEIB4M6TsA 0BCw== X-Gm-Message-State: APjAAAUDcRzZ2Xr+wv9NQKgDXDfc0IZWWPLOZKKpqAMJCnViqX7wpMX6 wmI8xN7AhMbf+YiABdTHAL4hwk9u X-Google-Smtp-Source: APXvYqzFx2MWxpXUCz0z8iQDYHA7GJIMp+xqAXJAPStbSe/WX6cEjVtURaH3bAbnK0ntWOUdROJOrQ== X-Received: by 2002:a50:ec03:: with SMTP id g3mr1100949edr.263.1552480830305; Wed, 13 Mar 2019 05:40:30 -0700 (PDT) Original-Received: from localhost ([145.5.121.125]) by smtp.gmail.com with ESMTPSA id fx9sm420408ejb.51.2019.03.13.05.40.29 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Mar 2019 05:40:29 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:156291 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, The clone method of eieio-instance-inheritor sets the slots of the new objects. For example: =20=20=20 (defclass A (eieio-instance-inheritor) ((foo :initarg :foo :initform "something"))) =20=20=20 (defvar a (A)) (defvar b (clone a)) (slot-boundp b :foo) ; =3D> t This is in contrast to the doc which says "All slots are unbound, except th= ose initialized with PARAMS". The original eieio implementation initialized the objects with unbound values like this: =E2=95=AD=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80 #68 =E2=94=80 emacs-source/lisp/emacs-lisp/eieio-base.el =E2=94=80= =E2=94=80 =E2=94=82 (let ((nobj (make-vector (length obj) eieio-unbound)) =E2=95=B0=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80 #68 =E2=94=80 The current implementation dispatches to cl-call-next-method. I am attachin= g a patch which preserves the call to cl-call-next-method. Vitalie --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Don-t-initialize-slots-of-eieio-instance-inheritor-o.patch >From 03e18e4eec518660e8dae6ae66ef21d4946f6220 Mon Sep 17 00:00:00 2001 From: Vitalie Spinu Date: Wed, 13 Mar 2019 13:32:22 +0100 Subject: [PATCH] Don't initialize slots of eieio-instance-inheritor objects on clone --- lisp/emacs-lisp/eieio-base.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lisp/emacs-lisp/eieio-base.el b/lisp/emacs-lisp/eieio-base.el index 3a0109877e..b2007a7476 100644 --- a/lisp/emacs-lisp/eieio-base.el +++ b/lisp/emacs-lisp/eieio-base.el @@ -64,10 +64,15 @@ eieio-instance-inheritor ;; Throw the regular signal. (cl-call-next-method))) -(cl-defmethod clone ((obj eieio-instance-inheritor) &rest _params) +(cl-defmethod clone ((obj eieio-instance-inheritor) &rest params) "Clone OBJ, initializing `:parent' to OBJ. All slots are unbound, except those initialized with PARAMS." - (let ((nobj (cl-call-next-method))) + (let ((nobj (cl-call-next-method obj))) + (dolist (descriptor (eieio-class-slots (class-of nobj))) + (let ((slot (eieio-slot-descriptor-name descriptor))) + (slot-makeunbound nobj slot))) + (when params + (shared-initialize nobj params)) (oset nobj parent-instance obj) nobj)) -- 2.17.1 --=-=-=--