From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Nicolas Petton Newsgroups: gmane.emacs.devel Subject: Re: map-put! and (setf (map-elt ...) ..) on lists Date: Mon, 17 Dec 2018 12:38:04 +0100 Message-ID: <87lg4otmcj.fsf@petton.fr> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1545046628 5286 195.159.176.226 (17 Dec 2018 11:37:08 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 17 Dec 2018 11:37:08 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 17 12:37:03 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 1gYrCp-0001GS-IZ for ged-emacs-devel@m.gmane.org; Mon, 17 Dec 2018 12:37:03 +0100 Original-Received: from localhost ([::1]:46142 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYrEv-0003NQ-TF for ged-emacs-devel@m.gmane.org; Mon, 17 Dec 2018 06:39:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52254) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYrEH-0003NH-1T for emacs-devel@gnu.org; Mon, 17 Dec 2018 06:38:34 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gYrEC-0004zO-Jv for emacs-devel@gnu.org; Mon, 17 Dec 2018 06:38:32 -0500 Original-Received: from petton.fr ([89.234.186.68]:47882) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gYrEC-0004wn-8Y for emacs-devel@gnu.org; Mon, 17 Dec 2018 06:38:28 -0500 In-Reply-To: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=petton.fr; s=mail; t=1545046705; bh=ZFFOr+QwAEtpbjPqn3haY0zAKWlQFEBruOphYSHBBSM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID:MIME-Version:Content-Type; b=tU3hOX/owgUhw6HCb+mNMvYCKWmNUs+SnkthhdvY5hO0jCLHaTP10UxVe4I/etgIxjJNnAA1hXTDGyOqORui1Gn+Dxy+7KM5t5di8VlF14m09UDHsGpNSq63Xix+sO6/HjQS13+SCBv7nmMm/5mo3BLVdGfsHiZocoxbVZup4J4= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 89.234.186.68 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:231871 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier writes: Hi Stefan, > The current handling of map-put on lists is very ad-hoc: > The gv-expander of `map-elt` tests if the arg is a list and if so > delegates to `alist-get`. > > It kind of works, but for a library that's supposed to be generic and > expandable to other map types, this is undesirable. > > So in the patch below I change this such that `map-elt` does not special > case lists any more. Instead `map-put!` is changed to signal a special > error when it can't do its job, and the gv-expander of `map-elt` catches > this error and delegates the job to a new non-side-effecting > `map-insert`. > > With this, we can add new map types via defmethod that work like lists > (i.e. that don't support inplace update but can still be modified via > `setf`). > > WDYT? I think it's a good step forward, thank you. I'd like to start thinking about adding support for plists in map.el. nico --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEE1AWqLIYsVPF+7mvg6LzXhmr8+XgFAlwXipwACgkQ6LzXhmr8 +XgTvwgAsMAWB9sfR/pFKzSp+tgSNmjJ5ZoddV3S2dxTMmDF6WGCFrOZD2udSQYr /fxcB1Ga0UsvpvvJx1CX4XxhX2eK24lGBIuKuXX7NOfxaBvJIPp3bWo1cBUvTO4w /RhORZnSoC+TjyY6+pr9EMs095i/68PBxnlxuoIIJNGnWQR6u075FQgEznoVFvXX wQXcoxtvAGoLp16e78Epud3fL13GR3O7WNGRFnoGaaIeYT3qaGR8eD2RkMuLRwvx jnVGEodsrvEz0d6N3ckaqjJ2GhJXBb85oIbxaznku18L0uwDNGZY9R9f9pVuyzvo pmsxqvpiMn1cCGWCQdzc2ZbltJ7/pA== =e3F4 -----END PGP SIGNATURE----- --=-=-=--