From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#64127: 30.0.50; mutate-constant warning with pure function Date: Sat, 17 Jun 2023 19:03:23 +0200 Message-ID: <22FA3A9A-A113-437C-A338-15A2BA7ADA59@gmail.com> References: <87ttv6b9zh.fsf@epfl.ch> <42E68F81-EDE7-45E4-AF08-BF420EE53F4B@gmail.com> <87jzw29hpq.fsf@epfl.ch> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25191"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 64127@debbugs.gnu.org To: Basil Contovounesios Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 17 19:04:25 2023 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 1qAZLd-0006MM-5T for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 17 Jun 2023 19:04:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qAZLO-0007vS-Aq; Sat, 17 Jun 2023 13:04:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qAZLJ-0007vC-Ka for bug-gnu-emacs@gnu.org; Sat, 17 Jun 2023 13:04:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qAZLG-0000nv-2B for bug-gnu-emacs@gnu.org; Sat, 17 Jun 2023 13:04:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qAZLF-0002Uj-Tu for bug-gnu-emacs@gnu.org; Sat, 17 Jun 2023 13:04:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 17 Jun 2023 17:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64127 X-GNU-PR-Package: emacs Original-Received: via spool by 64127-submit@debbugs.gnu.org id=B64127.16870214139548 (code B ref 64127); Sat, 17 Jun 2023 17:04:01 +0000 Original-Received: (at 64127) by debbugs.gnu.org; 17 Jun 2023 17:03:33 +0000 Original-Received: from localhost ([127.0.0.1]:52554 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAZKm-0002Tw-Jr for submit@debbugs.gnu.org; Sat, 17 Jun 2023 13:03:32 -0400 Original-Received: from mail-lf1-f53.google.com ([209.85.167.53]:42285) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAZKk-0002Tc-7S for 64127@debbugs.gnu.org; Sat, 17 Jun 2023 13:03:31 -0400 Original-Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-4f762b3227dso2339689e87.1 for <64127@debbugs.gnu.org>; Sat, 17 Jun 2023 10:03:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687021404; x=1689613404; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:from:to:cc:subject :date:message-id:reply-to; bh=guBTkr5JKsPLk+dXLVSbNqTRkg7nrYp5xEPWwuFOEyk=; b=aikLxljIaxigwzoBGFs295rvpbNEXplVfGEuxfahME6aLFeJJaHx2NYd8O3zbHeZNS 55UdAfrZGAGGJcs0hbFarOeipg+0N7q5bWC1ka/TxyjeTycZG3M/6Dp14fqVhdnfnNB/ DZBPmP3QHi6VEJFlPsmz10iX3yMcz5pMdKntCM25T+9zdFJkZt82vySmOjsesdiTQ3u4 TiJuAn0xIEZUWK9wMHYiKWF8rbzOvcIqu/WG7Q6/JHCGxYaaL3/M+737/dtgpefTQBNf 2NfTDpgj4CpQM5XNkSjHfRMuMI6rcE8PAmFB2HrhgNTf0KVsyz1KOsySpmGKuQw9h/N7 ei8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687021404; x=1689613404; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=guBTkr5JKsPLk+dXLVSbNqTRkg7nrYp5xEPWwuFOEyk=; b=KYEH9yMAwtMKXmARpHANvGPMeK7uKST4nz1zfo6B/R3B5T4Ks50Rz3AgtU9bg1gxkR g16X21TzYSdo7CG2S5Vd+ZLLpi+M4wjabac8PnS8b4eeFsrQQqY1R1vgltt381jzKBCJ q62OvPfNlVvasNoa1D+X4Qyyju1GsbaDzK6WaJ4/FuMN2nxmUFOMxtqqqagaNqjcqK4k 8O2K9N7vceypN68a09xEOYpRuT1bPUNC6fQvd+VrYhoHqdVjyyaQ4Bswgw3XQfMrQrtm +JR/x0c/1ThISaDs+agxiRAYheLMr33HQmbnqF/i6KDGJuBFEtpXVnXeX6WJcWpevw2H uyhQ== X-Gm-Message-State: AC+VfDxPBMIOiBp0u4OR/mK8nlPhgGQqKgiMQg01Ze8zjxuRtqD68g98 dmeQTJMGnYotbpqYfiP1Slc= X-Google-Smtp-Source: ACHHUZ5V0HpTJCuRb2ervWkx/Ha0w44u/lLTPRVUdhugzHKW5Ll1nu4e0fV6f7F0S+6XE2gVcEfZWg== X-Received: by 2002:a19:640e:0:b0:4f8:5510:c897 with SMTP id y14-20020a19640e000000b004f85510c897mr1841243lfb.18.1687021403919; Sat, 17 Jun 2023 10:03:23 -0700 (PDT) Original-Received: from smtpclient.apple (c188-150-165-235.bredband.tele2.se. [188.150.165.235]) by smtp.gmail.com with ESMTPSA id r24-20020ac24d18000000b004eed8de597csm3495731lfi.32.2023.06.17.10.03.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Jun 2023 10:03:23 -0700 (PDT) In-Reply-To: <87jzw29hpq.fsf@epfl.ch> X-Mailer: Apple Mail (2.3654.120.0.1.15) 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:263562 Archived-At: 17 juni 2023 kl. 18.28 skrev Basil Contovounesios : > Which approach do you think the dash.el library in GNU ELPA should > follow? It generally defines nondestructive operations over lists, = some > of which even claim in their docstring that they return a partial or > complete copy of their arguments (modulo the parts changed by the > operation). Its doc strings seem to talk a lot about how the functions returns a new = this or a copy of that. Maybe that provides the licence to return a = constant when those words are absent, or perhaps the users will just = assume mutability in absence of stern warnings. I don't know how dash.el = is used in practice, so perhaps it's prudent to stay off the `pure` = declarations. > Is it okay for a pure function to say it returns a copy in its > docstring, with the onus lying on the caller to realise that a pure > function call may be byte-compiled to a runtime constant? Or should = all > such functions be impurified? A pure function cannot in general be guaranteed to return an eq-unique = value. By definition it will, if all its arguments are constants, be = called at compile-time to generate a constant used in the program. There is nothing wrong with returning a newly created object from a = `pure`-declared function, as long as reasonable steps are taken to = prevent the returned value from being mutated. Depending on the context = this can be as simple as not saying that it returns a new object.