From mboxrd@z Thu Jan 1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Philipp Stephani
Newsgroups: gmane.emacs.bugs
Subject: bug#42147: 28.0.50; pure vs side-effect-free, missing optimizations?
Date: Wed, 29 Jul 2020 15:10:22 +0200
Message-ID:
References: <3A9CC2A3-8307-47B2-8D80-795C0AF020E1@acm.org>
<0433A879-C98D-4B1A-B85C-A15DA9289099@acm.org>
<1621669100.2102667.1593639091621@mail.yahoo.com>
<33C2E2C8-16A6-47A9-B3A4-8A5F43648E04@acm.org>
<51FE77F3-CA05-459A-9601-9E1EEBC1E2FE@acm.org>
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="34274"; mail-complaints-to="usenet@ciao.gmane.io"
Cc: Paul Eggert , Stefan Monnier ,
Andrea Corallo , 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 Wed Jul 29 15:11:11 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 1k0lrS-0008ok-B9
for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 29 Jul 2020 15:11:10 +0200
Original-Received: from localhost ([::1]:38676 helo=lists1p.gnu.org)
by lists.gnu.org with esmtp (Exim 4.90_1)
(envelope-from )
id 1k0lrQ-00088R-UB
for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 29 Jul 2020 09:11:08 -0400
Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38218)
by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from )
id 1k0lrK-00088L-SI
for bug-gnu-emacs@gnu.org; Wed, 29 Jul 2020 09:11:02 -0400
Original-Received: from debbugs.gnu.org ([209.51.188.43]:48804)
by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
(Exim 4.90_1) (envelope-from )
id 1k0lrK-0007OO-IG
for bug-gnu-emacs@gnu.org; Wed, 29 Jul 2020 09:11:02 -0400
Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
(envelope-from ) id 1k0lrK-00004s-Cm
for bug-gnu-emacs@gnu.org; Wed, 29 Jul 2020 09:11:02 -0400
X-Loop: help-debbugs@gnu.org
Resent-From: Philipp Stephani
Original-Sender: "Debbugs-submit"
Resent-CC: bug-gnu-emacs@gnu.org
Resent-Date: Wed, 29 Jul 2020 13:11: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.159602824332741
(code B ref 42147); Wed, 29 Jul 2020 13:11:02 +0000
Original-Received: (at 42147) by debbugs.gnu.org; 29 Jul 2020 13:10:43 +0000
Original-Received: from localhost ([127.0.0.1]:60350 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from )
id 1k0lr0-0008W1-K2
for submit@debbugs.gnu.org; Wed, 29 Jul 2020 09:10:42 -0400
Original-Received: from mail-ot1-f54.google.com ([209.85.210.54]:38242)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from ) id 1k0lqy-0008Vm-BZ
for 42147@debbugs.gnu.org; Wed, 29 Jul 2020 09:10:40 -0400
Original-Received: by mail-ot1-f54.google.com with SMTP id q9so1777702oth.5
for <42147@debbugs.gnu.org>; Wed, 29 Jul 2020 06:10:40 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to
:cc:content-transfer-encoding;
bh=FqlPmPmvZ2DC0CjuEyMmaz2rTBOB/zLVWIG/S475y6k=;
b=ren9zWm40PF+61tMmvcRScuSXf2WozvWuYz8wBD3tCzVgsZELlBuhw6VFoMT6oqVD1
1Bo0oOBCZga+NVE8bFz0ACwT/EC0WR+Ss3oXvq2lC6rb9NWFZiRsjhMe+ULcMnD34G9U
LsNhirMRtqgybknWjVpnMwV3p1IdzKyFfybQc/lK7bedWKiFLDTM8Yvea3cuKZ3inp2A
Vb6zqkOH865CkTAAw9lA4mYZTvDyNC1NJYqJn0YIoDqbl+zH6FEJ2yzm2tPzWpiueY79
jSTDupZ+TRKBTHS7UZ9/ZQbQl8vN2ZO6f31r5eLj7sOUiVB9IeeVN9037raB+8JZX8cP
uLnQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to:cc:content-transfer-encoding;
bh=FqlPmPmvZ2DC0CjuEyMmaz2rTBOB/zLVWIG/S475y6k=;
b=Mx7ke057Eb7tWZvDdpnE6tx3wH2MY40bnXeJqJHW0Xx9ow4rMx7KfcZtLlT5K+A1tF
ZF0bK9DQf/IFVjVF1E1Y5vwben8QkIS+FrAUZ8jdYQgtyVt+vl/r5G58tmVd/eKU98wE
wpQhu+VKjFUX96OGwxvw3wuLzesE81DUx1cvusTRFG74CNQJUwR05HcW0I41ADUdwhha
A7rkbZQcdcPI7aZGHU8U3Z+Hxb5o6oHkv4UzxGZ2sqg4UHsDgdYdYsUXbi/LTYQNeJg6
K9It2ntbf5/nNmOFxkJtJQif7MiDpXmzSOjE8GsjHKy96R7jMzvWbl4EGr6JiCvMXxgm
hm/g==
X-Gm-Message-State: AOAM532SsQ8YXThJtvk9u/yKPdMMDkjhLZKNjfa70Y/UM0J6+mUOKw4A
7CETZkbUdR0J/T0W+cLIzlIaYAQD/3m36KgR5GM=
X-Google-Smtp-Source: ABdhPJwhcEH5By3aFsLqmlIU0Us+LooVW/wFDWpc7eJ6fdiV3NC5uJAUVcGhhQbOwstIbIM4buylia98i01sPtsRJdo=
X-Received: by 2002:a9d:7995:: with SMTP id h21mr26325772otm.174.1596028234462;
Wed, 29 Jul 2020 06:10:34 -0700 (PDT)
In-Reply-To: <51FE77F3-CA05-459A-9601-9E1EEBC1E2FE@acm.org>
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:183657
Archived-At:
Am Sa., 25. Juli 2020 um 23:00 Uhr schrieb Mattias Engdeg=C3=A5rd :
>
> 25 juli 2020 kl. 22.11 skrev Philipp Stephani :
>
> > The manual states that
> > "This function [concat] always constructs a new string that is not
> > =E2=80=98eq=E2=80=99 to any existing string" so I don't see how it coul=
d ever be pure.
>
> Actually that part of the manual was corrected fairly recently, as that s=
tatement hasn't been true for decades.
>
> More to the point, the current set of functions marked as 'pure' are real=
ly the superset 'pure-absent-mutation': functions that are pure when it can=
be assumed that the arguments are not modified. This assumption can be bas=
ed on physical immutability (integers), by convention (string constants), o=
r anything else the compiler can prove such as control flow.
>
> There is also the question of what equality to use and here the answer is=
probably 'equal' since we are only dealing with immutables. (The return va=
lues of these functions cannot be considered mutable for obvious reasons, s=
o make-string is out.)
>
> If you want to rename the property accordingly then I won't object. In an=
y case, it is certainly a good idea to be precise about what the various se=
ts really mean.
It looks like these are really two separate concepts, which should be
documented separately and should get separate function properties:
- Fully-pure functions are guaranteed to either return results that
are "eql" or signal error data that is "equal-including-properties"
when given arguments that are pairwise "eql", for all possible
arguments, mutable or not.
- Pure-unless-mutable functions are a strict superset whose
restrictions to immutable arguments are guaranteed to either return
results or signal error data that are "equal-including-properties"
when given arguments that are immutable and pairwise
"equal-including-properties".
Both categories must be free of observable side effects as well.
>
> There are also some functions declared 'pure' that appear to have side ef=
fects: kbd, package-get-version
>
kbd can and should be made pure-unless-mutable at least.
package-get-version should be neither, but should be marked using a
third to-be-introduced property (e.g. "eval-when-compile") to state
the intention without resorting to hacks.