From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.devel Subject: RE: map-put! and (setf (map-elt ...) ..) on lists Date: Tue, 18 Dec 2018 07:42:12 -0800 (PST) Message-ID: <6cd20f0b-2131-47b4-b37a-6d94a67558bb@default> References: <87y38p4ely.fsf@tromey.com> <8b3d6cc4-43ac-48cc-be4c-917f601faa43@default> <87imzstm6v.fsf@petton.fr> <89a74aae-cc0d-4fea-aeef-1e4afdc518e5@default> <87bm5jm9eu.fsf@petton.fr> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1545148028 13600 195.159.176.226 (18 Dec 2018 15:47:08 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 18 Dec 2018 15:47:08 +0000 (UTC) Cc: Tom Tromey , emacs-devel@gnu.org To: Stefan Monnier , Nicolas Petton Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 18 16:47:04 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gZHaI-0003QV-Vr for ged-emacs-devel@m.gmane.org; Tue, 18 Dec 2018 16:47:03 +0100 Original-Received: from localhost ([::1]:54648 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZHcP-0008Im-Op for ged-emacs-devel@m.gmane.org; Tue, 18 Dec 2018 10:49:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43889) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZHVn-0003bE-He for emacs-devel@gnu.org; Tue, 18 Dec 2018 10:42:24 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZHVi-0008Gg-CJ for emacs-devel@gnu.org; Tue, 18 Dec 2018 10:42:21 -0500 Original-Received: from userp2120.oracle.com ([156.151.31.85]:48250) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZHVi-0008Fe-2G for emacs-devel@gnu.org; Tue, 18 Dec 2018 10:42:18 -0500 Original-Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wBIFYQf4046527; Tue, 18 Dec 2018 15:42:15 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=+tFwMD8NjgrUPnR0na59yw9pdAHN8Mi5LKm3djwm+sw=; b=ein4BkFMllo5FfFdmb4QxkT7zQamSjJwLvT/dRyAAHsyQNUa1LFzxoOcRhxl7xBHkRow +1eai/2whvVBlfvLzJCu6Wr8q5HrDz5hgaqMwO4wwq4AXpdRwHwtK3rzL0FBF42mdzpM AJvYDouq0CSBJ4JZQf+ZLlHFvUmy2tqODUysaf+Bp9V4/NaJ/fqFlzx6mGn3mpDPbtmf Dr1b2U6Vc7xpqh/dF24fu02JwL3sVPTx1N8sfliXl5I6EuVeJyJeAmJfr5vL7/nlDi8N 0z7VTd0RgeAmFbcWcZH0p1XCcKLDp6f1uhHfr+O+i03TDXkScAM8TRnG7It4dCaNkNQ6 IA== Original-Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2pct8qv3xj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 18 Dec 2018 15:42:14 +0000 Original-Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wBIFgDi4014927 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 18 Dec 2018 15:42:13 GMT Original-Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wBIFgDAH029589; Tue, 18 Dec 2018 15:42:13 GMT In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4771.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9111 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=750 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812180132 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.85 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:231906 Archived-At: > >> map-put!: > >> Associate KEY with VALUE in MAP and return VALUE. > >> If KEY is already present in MAP, replace the associated value > >> with VALUE. >=20 > Not sure which version you were looking at, The version I downloaded from Master on 2019-12-17, the same day I wrote that. (cl-defgeneric map-put! (map key value) "Associate KEY with VALUE in MAP and return VALUE. If KEY is already present in MAP, replace the associated value with VALUE." (map--dispatch map :list (let ((p (assoc key map))) (if p (setcdr p value) (error "No place to change the mapping for %S" key))) :hash-table (puthash key value map) :array (aset map key value))) > but what I see is: > "Associate KEY with VALUE in MAP. > If KEY is already present in MAP, replace the associated value > with VALUE. > This operates by modifying MAP in place. > If it cannot do that, it signals the `map-not-inplace' error. > If you want to insert an element without modifying MAP, use `map- > insert'." LGTM. Thanks for making that change/addition. > I think normal code should never call this function > directly and should use `(setf (map-elt ...) ..)` instead anyway! > So, even a longwinded name would be perfectly fine. 1. Maybe such a statement should be made somewhere for users, if it's not made already - and with maybe some description of what is meant by either "normal code" or (more likely) the abnormal code where it might make sense to use this. 2. +1 for a long-winded name, if Emacs wants to make the name proclaim that the function is destructive. Maybe something like `map-put-in-place' or `in-place-map-put' or `map-put-set' or `map-put-modify' (no, I don't have a great suggestion).