From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.emacs.help Subject: Re: `apply-partially` and hash tables Date: Sun, 20 Oct 2024 11:54:04 +0200 Message-ID: References: <861q0b2jpo.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="cQkcyun/MbXGvT4X" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16824"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 20 11:54:32 2024 Return-path: Envelope-to: geh-help-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 1t2Sdr-0004Eo-Tc for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 20 Oct 2024 11:54:31 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2SdX-0007ds-Tb; Sun, 20 Oct 2024 05:54:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t2SdV-0007dc-Bz for help-gnu-emacs@gnu.org; Sun, 20 Oct 2024 05:54:09 -0400 Original-Received: from mail.tuxteam.de ([5.199.139.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t2SdT-0000wR-JN for help-gnu-emacs@gnu.org; Sun, 20 Oct 2024 05:54:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=From:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:To:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=EWFYw3UC5EBkkrS61VsMuI8IzuXuENuiZ3/ZcaokS8c=; b=oxZla4MCmf7iGHSHKKBlz3/lyW bn2DwOBOvhcxmlbOiY2gUYVtPhgIXP4Zpc0iz7X/D1d5pBY1KB6nbDwQtVm6aFvK8dpcnJIbMl1aE IVE/aKzrLE7Gm4fVRe3EZp79+5/VC/mZY4cvfCyDs6zGK1kTPYRbc3XvKWkmw574OKCknXOrnMuPh YEQWOt6nsuLKjBgMSzYeGmwPycK5QqNO2W2G6Z7SHpl6VMMz8I51CGvZb1QCrWr4Ou/3ENauPY+2a xe+T325z0LtM9ehXkuWTkhPF79XyBttqOHV5we3+5HLvKeNijDjPzq5/cJX8EiKs3yzcHIgiagtr5 gQZfTJ+g==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.94.2) (envelope-from ) id 1t2SdQ-0004dS-4C for help-gnu-emacs@gnu.org; Sun, 20 Oct 2024 11:54:04 +0200 Content-Disposition: inline In-Reply-To: <861q0b2jpo.fsf@fastmail.fm> Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@tuxteam.de; helo=mail.tuxteam.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:148188 Archived-At: --cQkcyun/MbXGvT4X Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Oct 20, 2024 at 11:43:15AM +0200, Joost Kremers wrote: > Hi list, >=20 > A question that just came up: if I use `apply-partially` to create a > function that has a hash table as one of its fixed arguments, and then at > some later point add data to said hash table, it seems that this data is > visible to subsequent calls to the partially applied function: >=20 > ``` > (let* ((s #s(hash-table test equal data ("MGrt" "Mouton De Gruyter" > "OTS" "Utrecht School of Linguis= tics UiL-OTS"))) > (fn (apply-partially #'parsebib--expand-strings s))) > (puthash "BW" "Oxford: Blackwell Publishers" s) > (funcall fn "BW")) > "Oxford: Blackwell Publishers" > ``` >=20 > `parsebib--expand-strings` is a function that (among other things) does a > hash table look-up. The entry ("BW" "Oxford: Blackwell Publishers") is > added to the hash table after the function is created, but it can obvious= ly > still be found by it. >=20 > So my question: is this intended behaviour, something that I can rely on = to > continue to work, or is this an artefact of the implementation that may > change at any time in the future? This is an interesting question: it comes down to what can be considered "immutable". I guess a hash table doesn't count (as wouldn't a buffer, possibly a list or any other object with a complex "inner life"). Cheers --=20 t --cQkcyun/MbXGvT4X Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCZxTTNAAKCRAFyCz1etHa Ri/zAJ90j05SySwF1Zr9uZw11jEB3n3DlACfRpwBOLJKxkltKvTk93lYanzu2kY= =l06M -----END PGP SIGNATURE----- --cQkcyun/MbXGvT4X--