From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#49291: [akater] [PATCH] lisp/emacs-lisp/eieio.el (initialize-instance): Fix initform Date: Wed, 30 Jun 2021 09:39:46 -0400 Message-ID: References: Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31460"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: akater To: 49291@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 30 17:17:12 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1lybxg-0007w5-4E for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 30 Jun 2021 17:17:12 +0200 Original-Received: from localhost ([::1]:38034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lybxe-0003Di-V0 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 30 Jun 2021 11:17:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lybxW-0003DY-Fn for bug-gnu-emacs@gnu.org; Wed, 30 Jun 2021 11:17:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46945) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lybxW-0003BS-8j for bug-gnu-emacs@gnu.org; Wed, 30 Jun 2021 11:17:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lybxW-0005Cv-1D for bug-gnu-emacs@gnu.org; Wed, 30 Jun 2021 11:17:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Jun 2021 15:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49291 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 49291-submit@debbugs.gnu.org id=B49291.162506621920005 (code B ref 49291); Wed, 30 Jun 2021 15:17:01 +0000 Original-Received: (at 49291) by debbugs.gnu.org; 30 Jun 2021 15:16:59 +0000 Original-Received: from localhost ([127.0.0.1]:58491 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lybxS-0005Ca-SC for submit@debbugs.gnu.org; Wed, 30 Jun 2021 11:16:59 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:55225) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lybxQ-0005CN-3l for 49291@debbugs.gnu.org; Wed, 30 Jun 2021 11:16:58 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 1FB3B8064E; Wed, 30 Jun 2021 11:16:50 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id D431E80A5C; Wed, 30 Jun 2021 11:16:47 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1625066207; bh=nRkcXIm0U1vnaTMnYsE/Veqsog9QQpNDCm5nHGHxuDw=; h=Resent-To:Resent-From:Resent-Date:From:To:Cc:Subject:References: Date:In-Reply-To:From; b=O1S9SFpY8TikVKp+ursFWq8OYLg5XjCwQh8AERr+X12/FBclAaf+CNYj4+ugTGeLz 0Dxz0zMPgsbbPDFASIppA23p71zazH6zukTdanbfKMH1w65fH/y6/3ZtrN0G+WfQ0g gvcRQhg2tYo8pGQNejM+OXM96UxBeQKxCkqdZDwoBK2kQ37oGLgFFv5EEyJcnINdYP kDUkxBAnZkwWQd44sgjHCBF83DE+ltUu+tCwSh6l4/+rAtcwMNZzri+UlhUtZTkMzG G85v4L2RE95N1vduNVDQCVg+Gz9hrcYKuUIsS26Djcl/XTcBHB5SY6kJzGjqjBq2Et vb5Pf4IfAYqrg== Original-Received: from alfajor (unknown [45.72.205.238]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id A41851202DA; Wed, 30 Jun 2021 11:16:47 -0400 (EDT) Resent-Message-ID: Resent-To: 49291@debbugs.gnu.org Resent-From: Stefan Monnier Resent-Date: Wed, 30 Jun 2021 11:16:42 -0400 Original-Received: from mail01.iro.umontreal.ca by mail01.iro.umontreal.ca with LMTP id cNZZGSR03GAKUwAASs+2LQ (envelope-from ) for ; Wed, 30 Jun 2021 09:39:48 -0400 Original-Received: from mailscanner.iro.umontreal.ca (pmg1.iro.umontreal.ca [172.31.2.40]) by mail01.iro.umontreal.ca (Postfix) with ESMTPS id 4EE8E140E6B for ; Wed, 30 Jun 2021 09:39:48 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1625060388; bh=nRkcXIm0U1vnaTMnYsE/Veqsog9QQpNDCm5nHGHxuDw=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=Uu978xetG77ScJT6BMsMzURMxbNqagJ3vKFcMPMeAWrJJpiCIF3++hug24SrY6A44 meM+DSwkgrADujRxkIsgWq3CQLlCGXxT5CJNJsH65cTcCDgi7Us5TCHUnKoRsFR+Iu jIbUYQFW+/i8NOvq1UDvE2Uk6tmsakp+RTolIwjl3BeCbnEKn+/m14S4fkE6oChNMi yZnCmBmWKWWEipLvdOyzjpxGfRrI3JVutO/EAlAtxrDJ7lkPacm8qFMsy0uxVvYvVi JDcUKc/38X2vh/+tkYCoXL55axRpz6908jzbXBsW9BXzXo3PWGWE1Lk7cV0oIGJ+xf 5iEKlePPPtlbQ== Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 1C89D1001F9; Wed, 30 Jun 2021 09:39:48 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 483A4100040; Wed, 30 Jun 2021 09:39:47 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1625060387; bh=nRkcXIm0U1vnaTMnYsE/Veqsog9QQpNDCm5nHGHxuDw=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=esTWfUQsj1So9WzcVyZfaC1HaPLQwCIzgmZ0B57PLXAKz3kz3xYs2inUhth6S04mt fpiXTxn3D2gpz2Ig9jE7YFBURakIyiaz1skVq7lDVJLRTIG9v6f9XwyYMRiFcAMfnU zYMTOLUpE6fz6zWSUt3eCZ6LZANKh1crGqpyKBoIIMNMeoF9MmVVKl5RehN5d+CsC4 aXoS6lVbOmgnorx8cd07/JnZKtgDrf3VF28DmMyba0nfRZmf/9mhdo1f6l5ProXKao D/tbGDCUfeXNymukYWmPcp6XxNZ5cA1LN7pdR0TG7ZyVyC48p1LbJ1H07HiM8le4nR 1GsYtWvarjivw== Original-Received: from alfajor (unknown [45.72.205.238]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 1379712077D; Wed, 30 Jun 2021 09:39:47 -0400 (EDT) In-Reply-To: (Stefan Monnier's message of "Wed, 30 Jun 2021 09:32:32 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:209208 Archived-At: Stefan Monnier [2021-06-30 09:32:32] wrote: > This is not what happens in eieio. Rather, initform is evaluated even > when initarg is present. Good catch, thanks. > @@ -756,13 +756,15 @@ defclass eieio-default-superclass nil > (dotimes (i (length slots)) > ;; For each slot, see if we need to evaluate it. > (let* ((slot (aref slots i)) > + (slot-name (eieio-slot-descriptor-name slot)) > (initform (cl--slot-descriptor-initform slot))) > ;; Those slots whose initform is constant already have the right > ;; value set in the default-object. > - (unless (macroexp-const-p initform) > + (unless (or (rassq slot-name > + (eieio--class-initarg-tuples this-class)) > + (macroexp-const-p initform)) > ;; FIXME: We should be able to just do (aset this (+ i ) dflt)! > - (eieio-oset this (cl--slot-descriptor-name slot) > - (eval initform t)))))) > + (eieio-oset this slot-name (eval initform t)))))) > ;; Shared initialize will parse our slots for us. > (shared-initialize this slots)) Hmm... if I read this correctly, you prevents the (eval initform t) for all slots that were declared with `:initarg `, whereas AFAIK the right semantic is to prevent the (eval initform t) in the case where the corresponding was passed to `make-instance`. So we should pay attention to `slots` (the arg, not the local var) to decide whether to skip (eval initform t). Stefan