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#43557: 28.0.50; Please document which objects are mutable and which are not Date: Sat, 31 Oct 2020 16:54:37 +0100 Message-ID: References: <87mu0nv6y6.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3797"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 43557@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 31 16:55:15 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 1kYtDn-0000tx-KD for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 31 Oct 2020 16:55:15 +0100 Original-Received: from localhost ([::1]:57352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYtDm-0006vT-H7 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 31 Oct 2020 11:55:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43046) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYtDa-0006vM-GR for bug-gnu-emacs@gnu.org; Sat, 31 Oct 2020 11:55:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51023) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kYtDa-0002Nr-7S for bug-gnu-emacs@gnu.org; Sat, 31 Oct 2020 11:55:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kYtDa-0000oz-61 for bug-gnu-emacs@gnu.org; Sat, 31 Oct 2020 11:55: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: Sat, 31 Oct 2020 15:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43557 X-GNU-PR-Package: emacs Original-Received: via spool by 43557-submit@debbugs.gnu.org id=B43557.16041596963140 (code B ref 43557); Sat, 31 Oct 2020 15:55:02 +0000 Original-Received: (at 43557) by debbugs.gnu.org; 31 Oct 2020 15:54:56 +0000 Original-Received: from localhost ([127.0.0.1]:34336 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kYtDU-0000oa-Fl for submit@debbugs.gnu.org; Sat, 31 Oct 2020 11:54:56 -0400 Original-Received: from mail-ot1-f50.google.com ([209.85.210.50]:44553) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kYtDS-0000oN-Ji for 43557@debbugs.gnu.org; Sat, 31 Oct 2020 11:54:54 -0400 Original-Received: by mail-ot1-f50.google.com with SMTP id m26so8438828otk.11 for <43557@debbugs.gnu.org>; Sat, 31 Oct 2020 08:54:54 -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; bh=4dCiN5rXTM5XnYU71SSgUFKZon0PiPcatFUj3ERYuTg=; b=eRYHQjy4w2T0QUU3juWAwuy0aVuVjVgPUfMcNh0Pd4jetqn3JEisFXa6YtEW5Xc2a5 aXOb4HTfQBaD5X6CUUI+n1UZ27tv1+A+Xj8SbISEkOmxlRdGTwdlG4TeNwZHK4Dk3hy/ LTAZgqv4rI9xG74tRW0JKf0Zfg7kbuLzqqDRl8Oik3MSFDU0AyFqkLW6cFik2XkcGcJK gRR8SOUcXp10pCpOBjhe4bvzPyN61feBjfO7vziPfqAodSCi0Wwq/zgDYq9wPPOR11bQ PQunPelurjhNJjxug1+UtxfEdc7qrlj+x1a5DeJ/DQtxdxfS3A5vZ+a36TXws14RMKSo ZY1Q== 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; bh=4dCiN5rXTM5XnYU71SSgUFKZon0PiPcatFUj3ERYuTg=; b=Oip6BTtOqjGK0vKqC04/aSM8i+Bg9KqBxOPtImNf33YBY3zip2yKsE0g6lkheRhLvX OPaIMplwu7kYFKcxueXPFaQR2YkFC/APLDUvOmTxkGecueO98xpJXZM79xkJztsjiJa3 Rbf9Im8zj0OK5lozjT35XQCW0LEdJU9/URj5LayyxfoMB0ehJyo2Y2YRw2xHzJP/Z0J2 G1L/4OtLud1All/M0h9uqmt5prOVDa0ejaXBw4+lBdBBS9dg6VOIF+ZX3kcJcN541RXt Bhox7jI8uuxhg3bXy8GbVSCBsJDGu0oUCnyMsAM7bxE5TvNXxMGGDhAbvTTAX25l+beb 31Mg== X-Gm-Message-State: AOAM5335omOhecId0PfIvpxrMTt+B5uAyCJ6G/1CbbDPpyYXY0qZCvSC 6NzZwVYJYkTZzhA6pRm2Vtl2UUSjxfYA6o10v+A= X-Google-Smtp-Source: ABdhPJw+i+Lnv0TzCJidh97qpePMLcQTQnD3KtgBWFuvsMeY3u73umHNP6xeqM4IYRza9MS13z+Uclbzc0OZ8mIe5W4= X-Received: by 2002:a9d:6e88:: with SMTP id a8mr5489532otr.174.1604159688818; Sat, 31 Oct 2020 08:54:48 -0700 (PDT) In-Reply-To: <87mu0nv6y6.fsf@gnus.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:192280 Archived-At: Am Do., 15. Okt. 2020 um 17:34 Uhr schrieb Lars Ingebrigtsen : > > Philipp Stephani writes: > > > The "Mutability" section in the ELisp manual mentions that there are > > mutable and immutable objects, but (besides giving a few examples) > > doesn't document which objects are actually mutable. At the very least, > > there should be a list of functions that are guaranteed to return > > mutable objects, and a statement about the mutability of function return > > values in general. > > Reading the section, it seems pretty clear to me, and outlines the cases > where you can't assume mutability (even if the objects may appear to be > mutable). I disagree. "Pretty clear" would mean "allowing the reader to classify each Lisp expression w.r.t. the mutability of its value", and as the section only gives a few examples, it can't do that. What it should do in addition is provide rules on how to classify any given Lisp expression. Each possible Lisp expression has to fall into exactly one of three categories: - The value is mutable. - The value is immutable. - It is unspecified whether the value is mutable or immutable. Given that we can't document this for every Lisp function in existence, we need to pick some default, and document that default in the manual. Also, we need to document the cases where the default doesn't apply, either in the manual or in function docstrings. I'm happy to add the necessary documentation, but for that we first need a decision what the default is, and what the exceptions are. > > I'm not sure a list of mutable objects is a well-defined request, and > there are very few functions that can promise to return a mutable > object. (I mean, (list 1 2 immutable-list) is mutable, but can contain > elements that aren't.) Then the docstring of `list' and the ELisp manual should say that. The difference between shallow and deep immutability might not be clear to all readers, so it's important that it's documented as well. > > So I'm not sure whether what you're requesting is feasible. It must be feasible, otherwise programming in ELisp becomes, strictly speaking, impossible. Given code such as (let ((var (some-list-returning-function ...))) ...) it must be possible for programmers to derive whether (setcar var ...) is allowed from some set of rules plus the docstring of the function. This is not some theoretical problem: This bug was triggered by a code review where the author and reviewer disagreed what could be assumed about the mutability of the return value of arbitrary functions, so fixing this bug has very practical consequences.