From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#40671: [DOC] modify literal objects Date: Sat, 18 Apr 2020 14:54:32 -0700 (PDT) Message-ID: References: <87v9lzmdrw.fsf@laposte.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="33561"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Kevin Vigouroux , 40671-done@debbugs.gnu.org To: Paul Eggert , Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 18 23:55:31 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 1jPvQx-0008bD-DR for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 18 Apr 2020 23:55:31 +0200 Original-Received: from localhost ([::1]:33732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jPvQw-0008Ai-Ea for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 18 Apr 2020 17:55:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33574) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jPvQV-00088n-Gh for bug-gnu-emacs@gnu.org; Sat, 18 Apr 2020 17:55:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jPvQU-000571-Sz for bug-gnu-emacs@gnu.org; Sat, 18 Apr 2020 17:55:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60400) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jPvQU-00056t-GQ for bug-gnu-emacs@gnu.org; Sat, 18 Apr 2020 17:55:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jPvQU-0005i1-Eh for bug-gnu-emacs@gnu.org; Sat, 18 Apr 2020 17:55:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 Apr 2020 21:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40671 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 40671-done@debbugs.gnu.org id=D40671.158724690021934 (code D ref 40671); Sat, 18 Apr 2020 21:55:02 +0000 Original-Received: (at 40671-done) by debbugs.gnu.org; 18 Apr 2020 21:55:00 +0000 Original-Received: from localhost ([127.0.0.1]:43713 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jPvQR-0005hi-6q for submit@debbugs.gnu.org; Sat, 18 Apr 2020 17:55:00 -0400 Original-Received: from aserp2120.oracle.com ([141.146.126.78]:48968) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jPvQM-0005hN-51 for 40671-done@debbugs.gnu.org; Sat, 18 Apr 2020 17:54:58 -0400 Original-Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03ILmUu5151638; Sat, 18 Apr 2020 21:54:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=dOrl2LR6v6XWsFJaInodI2OBzdOZlOehhfiyP4uXHd4=; b=MoQOViHZb2XYW0WFNAucfqGgB5aDOEF7gw4qRz7d4mvhuwawXa1WFAc6tZ+avx9VcUck GtRcZMWxiHJNFtGm4QJSGwhYzoE2yIeyaVTyrT06xcv5VXqb2V6zGTl5KQnV2KotkpuZ 67cvhrWf53aF0uBTfiOfA996FSvy+CEqRiPZL9e/Z0OX+bnAa/K2LoVc25/GWVUjwlrx c2DDUvQmxv+qp8eOWRSmNquh0pH2RjpzBC9WVLzUZyfNu16nDCHZMQe89vsnZlar11JW 3tYtuz2UzUHvGLLHaXSm5ewC2ESVbN5wINyz6cmm+MwSE17cLbBQT6dSfr6pCciEeRNu Vw== Original-Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 30fsgkhyub-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 18 Apr 2020 21:54:37 +0000 Original-Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03ILmHwP067448; Sat, 18 Apr 2020 21:54:37 GMT Original-Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 30fvfd8g07-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 18 Apr 2020 21:54:37 +0000 Original-Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03ILsXJt006447; Sat, 18 Apr 2020 21:54:34 GMT In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4966.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9595 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 adultscore=0 bulkscore=0 mlxscore=0 malwarescore=0 suspectscore=0 spamscore=0 mlxlogscore=911 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004180181 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9595 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 mlxlogscore=961 malwarescore=0 clxscore=1011 spamscore=0 bulkscore=0 phishscore=0 suspectscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004180181 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:178602 Archived-At: OK, here's a nitpick, FWIW. ___ You say things such as this: "should be applied only to @dfn{mutable} lists, that is, lists constructed via @code{cons}, @code{list} or similar operations." That's not a usual meaning of "mutable". Your "that is" makes clear what you mean, sort of, I suppose. That part is clear enough, but it's not a good "definition" of "mutable". It's about code that always creates new list structure, versus code that might create new list structure only sometimes (e.g. the first time it's encountered). A quoted list, which you call "constant", is in fact mutable in some contexts. An immutable list would be one you couldn't ever change - it would truly be a constant. That can be true for the result of byte-compiling a quoted list. But it's not true in general for interpreted code. E.g., this example in (elisp) `Setcdr': (setq x '(1 2 3)) =E2=87=92 (1 2 3) (setcdr x '(4)) =E2=87=92 (4) x =E2=87=92 (1 4) What you're really trying to convey presumably is not that one CANNOT ever modify such a list, but that one SHOULD NOT modify such a list (e.g. because of what can happen to it with the byte compiler). That's something different, and I don't think the message comes across well. Similarly: "However, the other arguments (all but the last) must be mutable lists." "MUST" means you CANNOT do otherwise. Trying to do so might result in an error being raised, for example. And that's not always the case. Hence the gotcha, hence the need for a guideline: Don't do it; just say no. That text with "must" is immediately followed by: "A common pitfall is to use a quoted constant list..." And _that's_ the point. But together with your text saying you CANNOT modify it anyway, things get confusing. Modifying a quoted list is problematic, a gotcha, a pitfall, something to avoid. You SHOULD NOT do it precisely because you CAN do it sometimes. If you couldn't, e.g., if you were prevented from doing it by always raising an error, then there would be no gotcha, no reason to tell you not to do it. Anyway, you get the idea. BTW, "a quoted constant list" is a bit poorly worded, as well. (Yes, that text was already there.) The problem is using a quoted list sexp, which can have the effect of producing a constant list. It's not about quoting a list that is somehow already a constant. Quoting can _produce_ a constant. --- FWIW, Common Lisp doesn't talk about mutable or immutable lists (or other objects):=20 "The consequences are undefined if literal objects (including quoted objects) are destructively modified." Undefined. They CAN sometimes be destructively modified. And a proposal says to: "clarify that it is an error to destructively modify objects which are self-evaluating forms or which appear inside of a QUOTE special form." And it talks of: "modifying quoted data structures" Such wording makes clear which things we're talking about. Cltl says only: "implicit sharing of compiled data structures may result in unpredictable behavior if destructive operations are performed. However, CLtL does not explicitly allow or disallow destructive operations on constants." Unpredictable behavior. It doesn't say it's always impossible to modify such things. It says, in effect, don't try. That's what we should say for Emacs Lisp, since we do NOT "disallow modification of constants consistently in all situations." For Emacs Lisp this is a gotcha, so we need a SHOULD. If it were enforced as a MUST then we wouldn't need such a caveat. This was proposed for CL: "Disallowing modification of constants consistently in all situations, rather than just in compiled code, is proposed because in some compiled-only situations it may be difficult to distinguish between "compiled" and "interpreted" code." Whether "disallow" means raise an error in all such cases (which was proposed for Cltl) or just warn users not to do it and say the behavior is "undefined" (what Cltl did, and what Emacs should do), is a separate question. The point about trying to modify a quoted list, for Emacs Lisp, is this: Don't do it. Don't assume that you get new list structure each time it looks like a quoted list will be evaluated anew. It might be evaluated only once, and the result used as a constant thereafter. http://clhs.lisp.se/Issues/iss083_w.htm