From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: Instead of pcase Date: Tue, 02 Jan 2024 23:13:56 -0500 Message-ID: References: <878r5inysw.fsf@localhost> <878r5ewk81.fsf@localhost> <87h6jxm8d4.fsf@localhost> Reply-To: rms@gnu.org Content-Type: text/plain; charset=Utf-8 Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29561"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Ihor Radchenko Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jan 03 05:14:50 2024 Return-path: Envelope-to: ged-emacs-devel@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 1rKseX-0007Ux-Va for ged-emacs-devel@m.gmane-mx.org; Wed, 03 Jan 2024 05:14:50 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKsdj-0005nb-5e; Tue, 02 Jan 2024 23:13:59 -0500 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 1rKsdh-0005lL-CV for emacs-devel@gnu.org; Tue, 02 Jan 2024 23:13:57 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rKsdh-00049S-4Q; Tue, 02 Jan 2024 23:13:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=Date:References:Subject:In-Reply-To:To:From: mime-version; bh=97RLfJKyJBXtKvxENHJJH4N4JVI8pKeiZfNpFLCsnZc=; b=gwlH657vtVE6 /gdyMFlk4gbiFyUALNZs3sppw/W80XPkngVXJtDrpAmFmf41PbQ9wxU4fPnR1pJ3jroioOld9yJZI bekEp+eaiwzgbN+uEgSkjTQilFi1u9uh4MwMm6CIHKY0k4N3I6Ufd9Biqh3FDXP7WTqCar/lhc3KE 3SYfY4EUX3Hiw3YCRObkDg0aYQeFTimJpATabSUz76aXgpGM5N1zczBgyNXWIuIpoL7NKPFkvQz4B KMYN+yU13B+CTMpiuf6yG3+/QEB4Vx69mRd6Yj2NncK51MtkMgALaDes+hma89IfBhMfOpCPEg2Sa MEO2wRsyKFxPblb2+9QThA==; Original-Received: from rms by fencepost.gnu.org with local (Exim 4.90_1) (envelope-from ) id 1rKsdg-0003KD-Id; Tue, 02 Jan 2024 23:13:56 -0500 In-Reply-To: <87h6jxm8d4.fsf@localhost> (message from Ihor Radchenko on Mon, 01 Jan 2024 14:33:11 +0000) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:314476 Archived-At: [[[ To any NSA and FBI agents reading my email: please consider ]]] [[[ whether defending the US Constitution against all enemies, ]]] [[[ foreign or domestic, requires you to follow Snowden's example. ]]] > Let me try to illustrate the problem with another example: > ;; ALIST-VAL = '((:key1 . 1) (:key4 . 2)) > ;; Match alist key where the key is one of a know set of keys. > (match* (memq (alist-get key alist-val) '(:key1 :key2 :key3)) :key1) > >From the description of "constrained variable" construct, the above will > (1) test if ALIST-VAL contains a record with KEY=:key1 key; (2) test if > KEY=:key1 is one of :key1 :key2 :key3. What a strange example. This is connterintuitive and I could not see at first what it would mean. But I worked it out by following the rules. (match* PATTERN :key1) matches PATTERN against the data object :key1. (memq (alist-get key alist-val) '(:key1 :key2 :key3)) as a pattern means to match (alist-get key alist-val) aainst it, and if that matches, then call memq to determine whether this matches, It would be matched against :key1. Matching (alist-get key alist-val) against :key1 would succeed, so `key' would be bound to `key1'. So the memq call would return t. And the pattern would match, binding `key' to :key1. It isn't "wrong", but I can't see the point using that strange pattern. What purpose did you have in mind in writing it? Is there a simpler way to do that? -- Dr Richard Stallman (https://stallman.org) Chief GNUisance of the GNU Project (https://gnu.org) Founder, Free Software Foundation (https://fsf.org) Internet Hall-of-Famer (https://internethalloffame.org)