From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#34708: alist-get has unclear documentation Date: Sun, 3 Mar 2019 07:51:51 -0800 (PST) Message-ID: References: <87wolhr5k6.fsf@web.de> <87y35xdu4w.fsf@web.de> <87mumcdu7f.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="149279"; mail-complaints-to="usenet@blaine.gmane.org" Cc: Eric Abrahamsen , 34708@debbugs.gnu.org To: Michael Heerdegen , "Miguel V. S. Frasson" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Mar 03 16:54:28 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h0TRZ-000cbs-0c for geb-bug-gnu-emacs@m.gmane.org; Sun, 03 Mar 2019 16:54:25 +0100 Original-Received: from localhost ([127.0.0.1]:40888 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0TRX-0003ls-SB for geb-bug-gnu-emacs@m.gmane.org; Sun, 03 Mar 2019 10:54:23 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:60205) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0TRO-0003ku-Ed for bug-gnu-emacs@gnu.org; Sun, 03 Mar 2019 10:54:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h0TQE-0001wL-Lr for bug-gnu-emacs@gnu.org; Sun, 03 Mar 2019 10:53:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45098) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h0TQE-0001w1-Eh for bug-gnu-emacs@gnu.org; Sun, 03 Mar 2019 10:53:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h0TQE-0003cW-27 for bug-gnu-emacs@gnu.org; Sun, 03 Mar 2019 10:53:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 Mar 2019 15:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34708 X-GNU-PR-Package: emacs Original-Received: via spool by 34708-submit@debbugs.gnu.org id=B34708.155162832413845 (code B ref 34708); Sun, 03 Mar 2019 15:53:02 +0000 Original-Received: (at 34708) by debbugs.gnu.org; 3 Mar 2019 15:52:04 +0000 Original-Received: from localhost ([127.0.0.1]:58642 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h0TPH-0003bE-Vb for submit@debbugs.gnu.org; Sun, 03 Mar 2019 10:52:04 -0500 Original-Received: from userp2130.oracle.com ([156.151.31.86]:33334) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h0TPG-0003aj-CC for 34708@debbugs.gnu.org; Sun, 03 Mar 2019 10:52:02 -0500 Original-Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x23Fn7x2071631; Sun, 3 Mar 2019 15:51:55 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-2018-07-02; bh=9fBRgqCKOM+7VNIUiBLrf3Yda7m+razGxw1o4wyQnFo=; b=WWDtAupPWT/kiyHK2vTI+3fupaif4X4uuCFW8nuUHOMa/CkIbYprPcPkgK339hXSFDy7 rcQeNfbjHoUeJwojlRbISO6Zb5QJqf9AdXn+MLGunWeaJxpKK+xg9XLgv7GxTwv62K3S Y875bkLleMWY5D8GgZpU6CD8l4BUF5nGxTH2e14Md8TnKQgvP0oPHaQktKK6LbXRbqK+ dO9xOdEEDqGapiu/7OTdXN2tNbTVNteUz6VebvbX6aCu5ZLS/X08EBt8GWNlkwS5R9jP 1nEDPXrQZGPg3q3LwKCVehLbJD0+TO+UDcBMEkt6DDUAPdjJ1Wdw7UIpssS2vH2zhwrc Vw== Original-Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2qyh8tuepe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 03 Mar 2019 15:51:55 +0000 Original-Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x23Fps7k004567 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 3 Mar 2019 15:51:54 GMT Original-Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x23FpqSH002409; Sun, 3 Mar 2019 15:51:52 GMT In-Reply-To: <87mumcdu7f.fsf@web.de> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4810.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9183 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903030125 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:155996 Archived-At: > > I think the sentence below is a good and short explanation for the > > doc-string. > > > > The return value can be conveniently used as a generalized variable Lose "conveniently", please. > > (a place) to set the value associated with KEY in ALIST, like in the > > example (setf (alist-get key alist) new-value) >=20 > Thanks for the idea. I don't think we should explain it like this > however, because when evaluating >=20 > (setf (alist-get key alist) new-value) >=20 > the function `alist-get' is never called, so there is no return value. Yes. (But that text didn't say it was called, and it didn't mention a return value.) `setf' is a macro. Its PLACE arg serves as a _specification_ of a place (a "generalized variable") whose value is to be set. And "set" means create or update. It's not really about `alist-get' here; it's about `setf'. `alist-get' itself has nothing to do with using a generalized variable. > Of course what is sexy about place expressions is that it looks like > you would directly set the result of a function call, but what happens is > that setf doesn't evaluate the call but analyses it and builds and > evaluates code that leads to this result. Yes. But that's "just" plumbing. It's not important to explain that here, I think. In terms of describing the role of `alist-get' as a `setf' place it's not relevant, at a first approximation. That `setf' doesn't call `alist-get' but instead analyses the spec and builds code that does the right thing is not necessary for getting the main point that `alist-get' can be used with `setf' to specify an alist element to create or update. > Eric suggested to say "this form is a setf-able place" but this also > doesn't answer the question what this (form) is. `alist-get' is not a > form, it's the name of a function. In my opinion it would be cleaner > to say something like "the name of this function can be used to build > place expressions" or "can be used in place expressions" or so. > Better ideas welcome. Yes wrt the substance (content). But an active phrasing is often better than the passive "__ can be used". Say what this does by saying what you can do with it. You can use function `alist-get' in a PLACE-expression argument to `setf'. In this role it specifies an alist element whose value `setf' sets: (setf (alist-get KEY ALIST) NEW-VALUE) Here, `setf' sets the value part of an element of ALIST whose key is KEY to NEW-VALUE. It's important to not give the impression that there must be an _existing_ element with KEY. Showing an example can help dispel that mistake. (setq foo ()) (setf (alist-get 'a foo) 1 (alist-get 'b foo) 2) C-h v foo ; =3D=3D> ((b . 2) (a . 1))