From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrea Corallo via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#42147: 28.0.50; pure vs side-effect-free, missing optimizations? Date: Thu, 2 Jul 2020 10:59:54 +0000 (UTC) Message-ID: <775819003.2516724.1593687594435@mail.yahoo.com> References: <3A9CC2A3-8307-47B2-8D80-795C0AF020E1@acm.org> <0433A879-C98D-4B1A-B85C-A15DA9289099@acm.org> <1621669100.2102667.1593639091621@mail.yahoo.com> Reply-To: Andrea Corallo Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15870"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Paul Eggert , Stefan Monnier , 42147@debbugs.gnu.org To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jul 02 13:01:16 2020 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 1jqwxw-00041s-2S for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 02 Jul 2020 13:01:16 +0200 Original-Received: from localhost ([::1]:44348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jqwxu-0000HA-WD for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 02 Jul 2020 07:01:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jqwxi-0000DM-KB for bug-gnu-emacs@gnu.org; Thu, 02 Jul 2020 07:01:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42886) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jqwxi-0008Ju-AX for bug-gnu-emacs@gnu.org; Thu, 02 Jul 2020 07:01:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jqwxi-0001VO-8u for bug-gnu-emacs@gnu.org; Thu, 02 Jul 2020 07:01:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andrea Corallo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 02 Jul 2020 11:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42147 X-GNU-PR-Package: emacs Original-Received: via spool by 42147-submit@debbugs.gnu.org id=B42147.15936876145715 (code B ref 42147); Thu, 02 Jul 2020 11:01:02 +0000 Original-Received: (at 42147) by debbugs.gnu.org; 2 Jul 2020 11:00:14 +0000 Original-Received: from localhost ([127.0.0.1]:54432 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jqwww-0001U7-0x for submit@debbugs.gnu.org; Thu, 02 Jul 2020 07:00:14 -0400 Original-Received: from sonic313-20.consmr.mail.ir2.yahoo.com ([77.238.179.187]:40853) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jqwws-0001Ss-Ay for 42147@debbugs.gnu.org; Thu, 02 Jul 2020 07:00:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.it; s=s2048; t=1593687599; bh=dPrEkC8YVLoaAavaaKmN+7ZVO9MORuvdJ9QLmIidpHI=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From:Subject; b=OfOyItXJ8yQof+PrlgpPEv1gWVfQtaxaSk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__uhBBqq8_FSVURFM0n5chVBz0dl81Fcld9Lg9Q.uvMz0JMAUzJbfcZRzxO.isH9EVIwgSrgI hoyonUJMpJx2AG6JepG_eGXsX0qJr0WgklOlEXI0nq Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic313.consmr.mail.ir2.yahoo.com with HTTP; Thu, 2 Jul 2020 10:59:59 +0000 In-Reply-To: X-Mailer: WebService/1.1.16197 YMailNorrin Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0 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:182628 Archived-At: Mattias Engdeg=C3=A5rd writes: > 1 juli 2020 kl. 23.31 skrev Andrea Corallo : > >> Another reason why I'm interested is that I reuse these >> definitions in the native compiler. > > In that case there are probably more functions you may want to consider f= or purity -- what about: > > < > <=3D >=3D =3D /=3D > string< string=3D string-equal > eq eql equal > proper-list-p > identity > memq memql member > assq assql assoc Good point >> I guess for the most part I can just include the one I've missed. > > By all means, but do not take my word for the correctness of my list -- t= hink it through yourself. We mustn't err here. > >> I'm not only sure about the one operating on lists like `length' given t= he >> list may be modified in the runtime (?). > > Not sure why this would be an obstacle, but I could have overlooked > something important! Could you explain your thinking in greater > detail, and if possible provide an example of code that you think > might be miscompiled if 'length' or 'safe-length' were marked pure? No, thinking about I believe you are correct. I mixed in mind the fact that now the native compiler must handle correctly in the CFG also pure functions taking mutable objects (given we are adding them), but that is unrelated.=C2=A0 This is no problem for the bytecompiler given the constant folding is done only locally. So yes these are pure functions and so they should be marked. > I still wonder if there is any reason to limit arithmetic constant > folding to the portable fixnum range. Given that we don't evaluate > fixnump or bignump at compile-time, what observable effects would > constant-folding, say, (ash 1 32) have? Advice from deeper thinkers > solicited! I always thought the general idea is to respect the allocation side effect we have creating a bignum.=C2=A0 Not sure if the class of example yo= u have in mind here fits this case. Thanks =C2=A0 Andrea