From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 26 17:14:41 2024 Received: (at submit) by debbugs.gnu.org; 26 Apr 2024 21:14:41 +0000 Received: from localhost ([127.0.0.1]:38557 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s0Su0-0000Rf-5b for submit@debbugs.gnu.org; Fri, 26 Apr 2024 17:14:40 -0400 Received: from lists.gnu.org ([2001:470:142::17]:33174) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s0PsJ-0006cB-V8 for submit@debbugs.gnu.org; Fri, 26 Apr 2024 14:00:46 -0400 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 1s0Pru-0003ii-HG for bug-gnu-emacs@gnu.org; Fri, 26 Apr 2024 14:00:19 -0400 Received: from mail-yb1-xb33.google.com ([2607:f8b0:4864:20::b33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s0Prr-0003yp-U0 for bug-gnu-emacs@gnu.org; Fri, 26 Apr 2024 14:00:17 -0400 Received: by mail-yb1-xb33.google.com with SMTP id 3f1490d57ef6-de5acdb3838so969625276.1 for ; Fri, 26 Apr 2024 11:00:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714154414; x=1714759214; darn=gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=bHBir+ZO2Zw+5ixxDx8ueb+qTKEkgWsr3DRwspDl8QE=; b=S7WlAc08Ws3uvWjVYN0Atv1LEzH9X/MoispQ1L5LtWudeQ9yKe2iO952xAR0JZCFHe GP0Ho+9io1zpzwFbc0rOjNUM5iudmjjPBlReyl/897ZxJW0m+nVtNHJ62rzrErlZfn8f bQBkOQYto1SViwh+mKhJrr17v1y9d2tAULwCyQXK4+1Rt2T+hMKjUudDy1VdZCdBFtgL lkKXu2NP+bkqUvjDyo2SKPdHFNjiosbJnDhDONcCfyPJyZIDBvRDtohxhvc70SUXgCtY 59BO4AhdCiB7BJ5QVHQZP6vmMOZKQR9BQkN4wKKqI43GSJQmOPHC/90Utq5ZkjHYsBPz 8s3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714154414; x=1714759214; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=bHBir+ZO2Zw+5ixxDx8ueb+qTKEkgWsr3DRwspDl8QE=; b=oqH5CZVeo6vI9zlsmeBi8yv32kHH61btqlmPTKmLP8gQGBuKIX5wO+ijjXsnk5R7ba +v/Wp9cx7PvVsF1QO4NCJvPJRpjH6IvVnej5T+ZIUBMoSM5J/EiQi5Gcm+pgUplf4jP0 yMamltN17ivRp5CQEcCWNxjeLgq1wi2epA4bHx3d3wh9TQ8ArnFK0aAZ8uAwxMCXUInM C3hjEc82YToEqE2t0Iyd5bFt6ADmqIhct71N3H4K2p3v7klm0/l/P+dI3e+4yRxoto3t Khcn6UTj+ss9ZRROT/a8SnnF/aJkWuzb/wbNPaVcOyHxtKVk5OzsezmfbDsi8PWwmIC+ Ka8g== X-Gm-Message-State: AOJu0YzC8fsFkAiGmLHG9B3k/Xwjvqf5guk+GZrBVUINyvbQ2LjWSbG7 4KGJRY8zoLO49GzynT6hhmYIosfexu3sENPQCVa2dqf/TZHchkGVOW/nLstFEI00XyLpWEfn1eo VIO/Hfb74qJSRSlqrhVvsKA9nwWB5RG6w X-Google-Smtp-Source: AGHT+IFOebVImL3vkyzdTzvmqkl7gX7LCDanocPbr3RA3OfDotoGPTw1pKf0AuHRuPI+B3pwvsiqEnGZIJAuiHbY6+A= X-Received: by 2002:a25:b1a2:0:b0:dcf:c7ef:e4e0 with SMTP id h34-20020a25b1a2000000b00dcfc7efe4e0mr3788175ybj.1.1714154414005; Fri, 26 Apr 2024 11:00:14 -0700 (PDT) MIME-Version: 1.0 From: Marco Antoniotti Date: Fri, 26 Apr 2024 20:00:02 +0200 Message-ID: Subject: Problem in pcase-let? To: bug-gnu-emacs@gnu.org Content-Type: multipart/alternative; boundary="000000000000efe4de061703ac76" Received-SPF: pass client-ip=2607:f8b0:4864:20::b33; envelope-from=marcoxa@gmail.com; helo=mail-yb1-xb33.google.com 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, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Fri, 26 Apr 2024 17:14:38 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --000000000000efe4de061703ac76 Content-Type: text/plain; charset="UTF-8" Hi This is for GNU Emacs 29.2 (build 2, x86_64-w64-mingw32) of 2024-02-01 running on Windows 11. I just noticed the following with pcase-let and pcase. I believe this is a problem with pcase-let. The following is a IELM transcript. The second plet-case should, IMHO, fail. ELISP> (pcase-let ((`(let ,bs (*when *,c . ,r)) '(let ((foo 42)) (*when *1 2 3)))) (list 'bs bs 'c c 'r r)) (bs ((foo 42)) c 1 r (2 3)) ELISP> (pcase-let ((`(let ,bs (*when *,c . ,r)) '(let ((foo 42)) (*zot *1 2 3)))) (list 'bs bs 'c c 'r r)) (bs ((foo 42)) c 1 r (2 3)) ELISP> (pcase '(let ((foo 42)) (*when *1 2 3)) (`(let ,bs (*zot *,c . ,r)) (list 'bs bs 'c c 'r r))) nil pcase correctly fails to match *when *and *zot*, while pcase-let seems to happily go ahead. All the best -- Marco Antoniotti Somewhere over the Rainbow --000000000000efe4de061703ac76 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

This is for GNU Emacs 29.= 2 (build 2, x86_64-w64-mingw32) of 2024-02-01 running on Windows 11.
<= div>
I just noticed the following with pcase-let and = pcase.=C2=A0 I believe this is a problem with pcase-let.=C2=A0 The following is a IELM transcript.= =C2=A0 The second plet-case sh= ould, IMHO, fail.

ELISP> (pcase-let ((`(let ,bs (when ,c . ,r)) '(let= ((foo 42)) (when 1 2 3))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(li= st 'bs bs 'c c 'r r))
(bs
=C2=A0((foo 42))
=C2=A0c 1 r=
=C2=A0(2 3))
ELISP> (pcase-l= et ((`(let ,bs (when ,c . ,r)) '(let ((foo 42)) (zot 1 2 = 3))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(list 'bs bs 'c c 'r= r))
(bs
=C2=A0((foo 42))
=C2=A0c 1 r
=C2=A0(2 3))

ELISP= > (pcase '(let ((foo 42)) (when 1 2 3))
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0(`(let ,bs (zot ,c . ,r)) (list 'bs bs 'c c= 'r r)))
nil

pcase correctly fails to match when and zot, while pcase-= let seems to happily go ahead.

All the best=

-- =
Marco Antoniotti
Somewhere over the Rainbow
--000000000000efe4de061703ac76-- From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 27 12:12:11 2024 Received: (at 70597) by debbugs.gnu.org; 27 Apr 2024 16:12:11 +0000 Received: from localhost ([127.0.0.1]:49566 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s0kep-0000A7-AH for submit@debbugs.gnu.org; Sat, 27 Apr 2024 12:12:11 -0400 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]:61571) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s0ken-00009y-22 for 70597@debbugs.gnu.org; Sat, 27 Apr 2024 12:12:09 -0400 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2dfb4ea2bbfso7965881fa.2 for <70597@debbugs.gnu.org>; Sat, 27 Apr 2024 09:11:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714234304; x=1714839104; darn=debbugs.gnu.org; h=mime-version:date:references:in-reply-to:subject:to:from:message-id :from:to:cc:subject:date:message-id:reply-to; bh=2H/csHbUBFMBM838gGnS+ITTAqmW/4eBB5ixSQ9UJYw=; b=ZbCH3ANjtLOq33u5Yp67iDxOuKumD4QIjuFkt0WkvXUVqvzn05aEubLfVCBL8Hr07n v4ZJuqHyUM+vfLCJNE4/p5etvrg3R/8QOWuMAnJ8oMJXTRnyGCH3lPq7np5ApeYlqJyA b7DKwGYdKP48MaDt7Y+wIw8Trsl+bOMKpDjrahNYrvAFqmvLJF3V5JDFauDLVLUGhbCN syic3xShIjXbrSOSZSr8N5I0Y+iaPLW683oiFkJAEtnya3U3I5Y0SI67wwyqFGAyEVr4 Uq5627tAmvpClhZE9QfIGkN4XdYSipK6lpt4QJzCjfIBWsA6UPRO5j89V4pz5YgFp19x LZrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714234304; x=1714839104; h=mime-version:date:references:in-reply-to:subject:to:from:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2H/csHbUBFMBM838gGnS+ITTAqmW/4eBB5ixSQ9UJYw=; b=aOx5eRjTDizyyJ7z2L80LLCtgj6bjFA1QloE5ZoxMGlMPZNaikjvAZPDunRFh3Hbck wHgfkW6xidffkkqB83rL+K03VyFpPWBSuNL84LqfW9H6SBiCsMbcxg0jgLBW0UOWjvMV 1dYNXk5HrdbHECCV26SS+DjWuJFRz6Sokn47fxt0jzfeffG76PASVjkZTbg6GuiSOqvo vn7jqRnY4yU+U41xHKNyDEvdBiLu6byLg+F3F7G6fZIAJeghDAExEUpbEshX4swpZs7E EjcW6nk0aocfWRyIe9DbXR4iZtmZPz1LFdUog4CoYeu94M1LRiwe0RplRiOTAJ/NwAXY jbFQ== X-Forwarded-Encrypted: i=1; AJvYcCW1cA7GhNhoGRsHtaOYqTi2rwyxTik9B5pT8TGhvy6e1aAZ4utdclwh+IddQoqVr3xouRyX7lwkTVz4Q1GsIjHxy5a5NgY= X-Gm-Message-State: AOJu0Yzc4Nhifw7LsTxZrCRvBFQkkLRIogYREc3Ys9R0RLrzjJF+7JGK CIgMHb5ON3kKEgUbxtNKMmeVrHBzJlEPvkV6QXt0VmYblMgC/MD9 X-Google-Smtp-Source: AGHT+IEwuxWPnLE2eok8TXH8u9mGUTBiX2wA/w6UtyDebTYqfEmMvvG7VlReqm6A24IKqgW4C6zdHw== X-Received: by 2002:a2e:9545:0:b0:2da:bbf4:81b8 with SMTP id t5-20020a2e9545000000b002dabbf481b8mr3088454ljh.14.1714234303638; Sat, 27 Apr 2024 09:11:43 -0700 (PDT) Received: from keynux ([2a01:e0a:505:3460:1c18:688d:ece4:372e]) by smtp.gmail.com with ESMTPSA id r21-20020a05600c35d500b0041bf45c0665sm1218855wmq.15.2024.04.27.09.11.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Apr 2024 09:11:43 -0700 (PDT) Message-ID: <662d23bf.050a0220.a4e2f.3f45@mx.google.com> Received: by keynux (sSMTP sendmail emulation); Sat, 27 Apr 2024 18:11:41 +0200 From: Bruno Barbier To: Marco Antoniotti , 70597@debbugs.gnu.org Subject: Re: bug#70597: Problem in pcase-let? In-Reply-To: References: Date: Sat, 27 Apr 2024 18:11:41 +0200 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 70597 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Marco, I'm not a maintainer but let me try to explain; I'm sure someone will correct me if I'm wrong. In short: not a bug. If I read your examples correctly, your problem could be reduced to this: (using org mode syntax, I hope it's ok): #+begin_src elisp (pcase-let ((`(A *,c . ,r) '(A *1 2 3))) (list c r)) #+end_src #+RESULTS: : (2 (3)) #+begin_src elisp (pcase-let ((`(A *,c . ,r) '(B *1 2 3))) (list c r)) #+end_src #+RESULTS: : (2 (3)) #+begin_src elisp (pcase '(A *1 2 3) (`(B *,c . ,r) (list c r))) #+end_src #+RESULTS: : nil The pcase-let documentation (describe-function 'pcase-let) says this: | Each EXP should match its respective PATTERN (i.e. be of structure | compatible to PATTERN); a mismatch may signal an error or may go | undetected, binding variables to arbitrary values, such as nil. Both of your pcase-let examples are actually undefined, because the patterns don't match in *both* cases. pcase-let works as documented: it did bind some variables to arbitrary values. That one matches (note the space between * and 1): #+begin_src elisp (pcase-let ((`(A * ,c . ,r) '(A * 1 2 3))) (list c r)) #+end_src #+RESULTS: : (1 (2 3)) That one doesn't match either (replacing * with WORD), but same result that your 2 pcase-let examples: #+begin_src elisp (pcase-let ((`(A *,c . ,r) '(A WORD1 2 3))) (list c r)) #+end_src #+RESULTS: : (2 (3)) Note that *1 is one symbol whose name is "*1". Your pattern `(*,c) is looking for the symbol whose name is "*", followed by the value for c. You may test your pattern, manually binding c to some value, to see that you get a list containing 2 values: #+begin_src elisp (let ((c 1)) `(*,c)) #+end_src #+RESULTS: : (* 1) Hoping this helps, Bruno From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 27 18:29:21 2024 Received: (at 70597) by debbugs.gnu.org; 27 Apr 2024 22:29:21 +0000 Received: from localhost ([127.0.0.1]:49794 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s0qXo-0001c9-Cj for submit@debbugs.gnu.org; Sat, 27 Apr 2024 18:29:20 -0400 Received: from mail-yw1-x112d.google.com ([2607:f8b0:4864:20::112d]:45060) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s0qXl-0001c1-N8 for 70597@debbugs.gnu.org; Sat, 27 Apr 2024 18:29:19 -0400 Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-617d25b2bc4so36182967b3.2 for <70597@debbugs.gnu.org>; Sat, 27 Apr 2024 15:28:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714256933; x=1714861733; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=O1LRTnnQJYx68v572nHp+StdPPNe+/SpzVKnVkkBdco=; b=f4FMlsjb/mB1WkMcbvVEJoi1ofSqthemBVSnUjMfwz8Q7ivRKLb43/nvpD1ipbWu+y Ls6YQGMhzCzEk2v+WPbZgkaeGKTkhAXjQuX/gZBt3uiDknkb0l4/3IUSP2Ul6AmnDfRX YjXC52T+cI7Ldq0TaYpqv2H98Kh+O9z1gavhIyqDEQQPb2tOD5TaYx5xwvlOZM8anmx2 7vAJOKgdQ+jdobNP2hsdAmvWshytF0QD2SyXRlLjwQy3QJG+LwknTDF5OEPL0pjx8cJk h7N+ekLjrOiZX0tYbHxioUL5FGGeGzbtdnaEQJnttDx2ndCUKIVP/MaKE0Ve9GXYHkry VQzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714256933; x=1714861733; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=O1LRTnnQJYx68v572nHp+StdPPNe+/SpzVKnVkkBdco=; b=fHp3E6dvjWUU/taXP56vm4a7NT7qP7OzoMXJ3z4qNRdJhiWoKa2HAW10DA68H65Pji meAVdpONB/HTWJQH+lSdCnzA2Du0foxmpMN9O4sd3mR+V4sBqbHqOUrmbYuUhzU0y7qb T3Jj6kZHmm6vAFp6wmwxoFtHUdQUHshAtWunfDzGz+GQPEJxAMeI1EV5iBMyR/87py7l WQvRlZJPc7ykZwgf6v1YM2brEG+azhxqwuk6fSWcRUCOhfiI94Hx8Ybr7KV7dcyowCH1 YtDV8Ylg1wZ6KdLgE8hvLYHrxD7Arl8TPRc59xXedKF/h1oM3GrsakNAI2bCiTaL2GzD YW3A== X-Gm-Message-State: AOJu0YzwTCAmBJ2jQ4WeF+qY37e4P3UV+9thDRyMjblWgaFbENLrhZ7d 5XaYyt9gRSpcSxMN5CFG4RhKY5efy6q4PO/DZtgPV980m2eGT/GMGI1at4KN5KMsZOTJByJoMVZ JDihtaE+Euk0q2FYYKziprnlh8AeV41G8Ljk= X-Google-Smtp-Source: AGHT+IH8iCTcdqw681nY6nVIos39cucFig0HaT+Q5CL/ub+/QYk8rreSxEDSk6SMtG11CyMMUYwCpRo10CU/MJfuDBE= X-Received: by 2002:a05:690c:7448:b0:618:92bd:9334 with SMTP id ju8-20020a05690c744800b0061892bd9334mr3544860ywb.43.1714256932655; Sat, 27 Apr 2024 15:28:52 -0700 (PDT) MIME-Version: 1.0 References: <662d23bf.050a0220.a4e2f.3f45@mx.google.com> In-Reply-To: <662d23bf.050a0220.a4e2f.3f45@mx.google.com> From: Marco Antoniotti Date: Sun, 28 Apr 2024 00:28:41 +0200 Message-ID: Subject: Re: bug#70597: Problem in pcase-let? To: Bruno Barbier Content-Type: multipart/alternative; boundary="000000000000865b7006171b8b7a" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 70597 Cc: 70597@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --000000000000865b7006171b8b7a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Bruno Thank you for the reply, but sorry. IMHO it is a bug, At a minimum, because pcase and pcase-let behave differently. I may be inclined to accept the explanation that the documentation about pcase-let allows for the behavior I find incorrect; that does not mean that the behavior is what is normally expected. Pattern matchers do ... pattern matching. If you allow quasiquotes or "incomplete specifications" (pick your preferred pattern matching terminology), then you should honor the expectations; hence two symbols that are not eq do not match. Also note that I do not have any star (*) operators in my examples. Again, the machinery is there, cfr, the example below, which selects the second clause. ELISP> *(pcase '(1 2 3 4) (`(1 2 ,x 5) (list 42 x)) (`(1 ,x 3 4) (list 666 x)))* *(666 2)* All the best MA On Sat, Apr 27, 2024 at 6:11=E2=80=AFPM Bruno Barbier = wrote: > > Hi Marco, > > I'm not a maintainer but let me try to explain; I'm sure someone will > correct me if I'm wrong. > > In short: not a bug. > > If I read your examples correctly, your problem could be reduced to this: > (using org mode syntax, I hope it's ok): > > #+begin_src elisp > (pcase-let > ((`(A *,c . ,r) '(A *1 2 3))) > (list c r)) > #+end_src > > #+RESULTS: > : (2 (3)) > > > #+begin_src elisp > (pcase-let > ((`(A *,c . ,r) '(B *1 2 3))) > (list c r)) > #+end_src > > #+RESULTS: > : (2 (3)) > > #+begin_src elisp > (pcase '(A *1 2 3) > (`(B *,c . ,r) (list c r))) > #+end_src > > #+RESULTS: > : nil > > > The pcase-let documentation (describe-function 'pcase-let) says this: > > | Each EXP should match its respective PATTERN (i.e. be of structur= e > | compatible to PATTERN); a mismatch may signal an error or may go > | undetected, binding variables to arbitrary values, such as nil. > > > Both of your pcase-let examples are actually undefined, because the > patterns don't match in *both* cases. pcase-let works as documented: > it did bind some variables to arbitrary values. > > That one matches (note the space between * and 1): > #+begin_src elisp > (pcase-let > ((`(A * ,c . ,r) '(A * 1 2 3))) > (list c r)) > #+end_src > > #+RESULTS: > : (1 (2 3)) > > That one doesn't match either (replacing * with WORD), but same > result that your 2 pcase-let examples: > #+begin_src elisp > (pcase-let > ((`(A *,c . ,r) '(A WORD1 2 3))) > (list c r)) > #+end_src > > #+RESULTS: > : (2 (3)) > > > Note that *1 is one symbol whose name is "*1". Your pattern `(*,c) is > looking for the symbol whose name is "*", followed by the value for c. > > You may test your pattern, manually binding c to some value, to see > that you get a list containing 2 values: > > #+begin_src elisp > (let ((c 1)) > `(*,c)) > #+end_src > > #+RESULTS: > : (* 1) > > Hoping this helps, > > Bruno > --=20 Marco Antoniotti Somewhere over the Rainbow --000000000000865b7006171b8b7a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Bruno

Thank you for the r= eply, but sorry.=C2=A0 IMHO it is a bug,=C2=A0 At a minimum, because pcase and pcase-let behave differently.

I= may be inclined to accept the explanation that the documentation about pcase-let allows for the behavior= I find incorrect; that does not mean that the behavior is what is normally= expected.

Pattern matchers do ... pattern matching.=C2= =A0 If you allow quasiquotes or "incomplete specifications" (pick= your preferred pattern matching terminology), then you should honor the ex= pectations; hence two symbols that are not eq do not match.=C2=A0 Also note that I do not have any star (= *) operators in my examples.

Again, the machinery is there, cfr, the example= below, which selects the second clause.

ELISP> (pcase '(1 2 3 4)
=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (`(1 2 ,x 5) (list 42 x))
=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (`(1 ,x 3 4) (list 666 = x)))
(666 2)<= /i>

All the best

M= A



<= div dir=3D"ltr" class=3D"gmail_attr">On Sat, Apr 27, 2024 at 6:11=E2=80=AFP= M Bruno Barbier <brubar.cs@gmail.com> wrote:

Hi Marco,

I'm not a maintainer but let me try to explain; I'm sure someone wi= ll
correct me if I'm wrong.

In short: not a bug.

If I read your examples correctly, your problem could be reduced to this: (using org mode syntax, I hope it's ok):

=C2=A0 =C2=A0#+begin_src elisp
=C2=A0 =C2=A0 =C2=A0(pcase-let
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0((`(A *,c . ,r) '(A *1 2 3)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0(list c r))
=C2=A0 =C2=A0#+end_src

=C2=A0 =C2=A0#+RESULTS:
=C2=A0 =C2=A0: (2 (3))


=C2=A0 =C2=A0#+begin_src elisp
=C2=A0 =C2=A0 =C2=A0(pcase-let
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0((`(A *,c . ,r) '(B *1 2 3)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0(list c r))
=C2=A0 =C2=A0#+end_src

=C2=A0 =C2=A0#+RESULTS:
=C2=A0 =C2=A0: (2 (3))

=C2=A0 =C2=A0#+begin_src elisp
=C2=A0 =C2=A0 =C2=A0(pcase '(A *1 2 3)
=C2=A0 =C2=A0 =C2=A0 =C2=A0(`(B *,c . ,r) (list c r)))
=C2=A0 =C2=A0#+end_src

=C2=A0 =C2=A0#+RESULTS:
=C2=A0 =C2=A0: nil


The pcase-let documentation (describe-function 'pcase-let) says this:
=C2=A0 =C2=A0|=C2=A0 =C2=A0 Each EXP should match its respective PATTERN (i= .e. be of structure
=C2=A0 =C2=A0|=C2=A0 =C2=A0 compatible to PATTERN); a mismatch may signal a= n error or may go
=C2=A0 =C2=A0|=C2=A0 =C2=A0 undetected, binding variables to arbitrary valu= es, such as nil.


Both of your pcase-let examples are actually undefined, because the
patterns don't match in *both* cases.=C2=A0 pcase-let works as document= ed:
it did bind some variables to arbitrary values.

That one matches (note the space between * and 1):
=C2=A0 =C2=A0#+begin_src elisp
=C2=A0 =C2=A0 =C2=A0(pcase-let
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0((`(A * ,c . ,r) '(A * 1 2 3)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0(list c r))
=C2=A0 =C2=A0#+end_src

=C2=A0 =C2=A0#+RESULTS:
=C2=A0 =C2=A0: (1 (2 3))

That one doesn't match either (replacing * with WORD), but same
result that your 2 pcase-let examples:
=C2=A0 =C2=A0#+begin_src elisp
=C2=A0 =C2=A0 =C2=A0(pcase-let
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0((`(A *,c . ,r) '(A WORD1 2 3)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0(list c r))
=C2=A0 =C2=A0#+end_src

=C2=A0 =C2=A0#+RESULTS:
=C2=A0 =C2=A0: (2 (3))


Note that *1 is one symbol whose name is "*1".=C2=A0 Your pattern= `(*,c) is
looking for the symbol whose name is "*", followed by the value f= or c.

You may test your pattern, manually binding c to some value, to see
that you get a list containing 2 values:

=C2=A0 =C2=A0#+begin_src elisp
=C2=A0 =C2=A0 =C2=A0(let ((c 1))
=C2=A0 =C2=A0 =C2=A0 =C2=A0`(*,c))
=C2=A0 =C2=A0#+end_src

=C2=A0 =C2=A0#+RESULTS:
=C2=A0 =C2=A0: (* 1)

Hoping this helps,

Bruno


--
Marco Antonio= tti
Somewhere over the Rainbow
--000000000000865b7006171b8b7a-- From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 28 06:01:49 2024 Received: (at 70597) by debbugs.gnu.org; 28 Apr 2024 10:01:49 +0000 Received: from localhost ([127.0.0.1]:50118 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s11Lw-0004Y0-Sl for submit@debbugs.gnu.org; Sun, 28 Apr 2024 06:01:49 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:54678) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s11Lu-0004Xu-Iy for 70597@debbugs.gnu.org; Sun, 28 Apr 2024 06:01:47 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-346406a5fb9so2980564f8f.1 for <70597@debbugs.gnu.org>; Sun, 28 Apr 2024 03:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714298481; x=1714903281; darn=debbugs.gnu.org; h=mime-version:date:references:in-reply-to:subject:cc:to:from :message-id:from:to:cc:subject:date:message-id:reply-to; bh=NqgYy7n35hLFK2RPUGMdsT+Q+6WOlej/WR4MH5f2Qvc=; b=jWHgh2l3bkmdA3UEfF2BZe4Zpk0cYfq5okFgBqyDBU3K8WD6euHPigLEYV5u0/FOE4 gK3Gbwkr38EZjiyBj06xYrQaZ1/bwse4C0PCoVKo2goYPCMl2x40eGnucSQvTC4i7Md/ fanPePwy+xWv8EDU3aP2/3c0iI4M4zMuHMHfF6Miz/BqIjetMFN33HdcJNNG/SNEKvbI 7DY5+4o3C5nfJ2SPavqUpBF1hcoMAuIYEigBYoG+fBFga16bDzMLbPIUW+R4jZ/Opxgy 33BmC6wP80uq2d/tRc98bbI7wp4+ahEixdlI8oyUFw6+byE0tR1+EgB0swoL+46ZfMVU Ogrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714298481; x=1714903281; h=mime-version:date:references:in-reply-to:subject:cc:to:from :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=NqgYy7n35hLFK2RPUGMdsT+Q+6WOlej/WR4MH5f2Qvc=; b=cx+5mFz9tZ8M5axqfPgCWSUlC7yUlOVGCzYUrsWZ3h47XG8RTTiIiHgis1WmxtsXHk 8JIPwOuddOKoUBOkX1yCUODq9H0Mq0yWmDYUOkQ+itpNbjVQh3PhwdU5VzT7GNhwlrpJ 7cOBiGHJGbuoeX18Mye/8aVw7EJ3u7ZawEazfKWpjbUy7uM06Qb+ugU7/J0XkuMGiMu4 5ysUZLXJ1VNVFDO55vBxpsIse8qTta9eMeothbGO13DX1ACTXJwnBhx1pnNMaktcGZYx iQMhbfzz7LAg6LuliyFHTdioUhbtwz3ZI5leZhS+NZo2C/GG6VGwIwZl6uJL0LkcPOYd GZfA== X-Gm-Message-State: AOJu0Yz5wf+vrG9pGQyyLRqE+uPcqFeIXqiGjO9gbTe/NRo6w2zeI+22 wiQGOPEBUDHeA5quso4GfXi/q382KbwPnqKLt7n1rFQ5X0dfRDVy X-Google-Smtp-Source: AGHT+IG5oxvKz+9fNxTJfhcJG534hZdpJNfRryfjsVs5MA0b7iqtiG/6Lxpj2hUNDNMj89NFTf2gYA== X-Received: by 2002:a05:600c:450b:b0:41b:f022:8e69 with SMTP id t11-20020a05600c450b00b0041bf0228e69mr1966168wmo.19.1714298481039; Sun, 28 Apr 2024 03:01:21 -0700 (PDT) Received: from keynux ([2a01:e0a:505:3460:1c18:688d:ece4:372e]) by smtp.gmail.com with ESMTPSA id h9-20020a05600c350900b0041c120dd345sm1968717wmq.21.2024.04.28.03.01.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 03:01:20 -0700 (PDT) Message-ID: <662e1e70.050a0220.3a3a2.45d1@mx.google.com> Received: by keynux (sSMTP sendmail emulation); Sun, 28 Apr 2024 12:01:19 +0200 From: Bruno Barbier To: Marco Antoniotti Subject: Re: bug#70597: Problem in pcase-let? In-Reply-To: References: <662d23bf.050a0220.a4e2f.3f45@mx.google.com> Date: Sun, 28 Apr 2024 12:01:18 +0200 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 70597 Cc: 70597@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Marco, Marco Antoniotti writes: > Hi Bruno > > Thank you for the reply, but sorry. IMHO it is a bug, At a minimum, > because pcase and pcase-let behave differently. > I may be inclined to accept the explanation that the documentation about > pcase-let allows for the behavior I find incorrect; that does not mean that > the behavior is what is normally expected. > > Pattern matchers do ... pattern matching. If you allow quasiquotes or > "incomplete specifications" (pick your preferred pattern matching > terminology), then you should honor the expectations; hence two symbols > that are not eq do not match. So, you would prefer for pcase-let to always signal an error if a pattern doesn't match. It makes sense. And it looks like the issue has already been raised: see bug#19670. (see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19670) > Also note that I do not have any star (*) operators in my examples. Thanks for mentionning this. I now see that you carefully crafted your HTML version, but, I only used the text version (that is less readable and contains plenty of stars). Sorry about the noise, explaining how to parse generated lightweight markup as elisp :) > Again, the machinery is there, cfr, the example below, which selects the > second clause. > > ELISP> > > *(pcase '(1 2 3 4) (`(1 2 ,x 5) (list 42 x)) (`(1 ,x 3 > 4) (list 666 x)))* > *(666 2)* I'm not sure it's that obvious: pcase doesn't really make a difference between match and no match: (eq (pcase 'b (`a t) (`b nil)) (pcase 'c (`a t) (`b nil))) ==> t If your request is really like bug#19670, further discussion should probably go there. All the best, Bruno From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 28 06:07:00 2024 Received: (at 70597) by debbugs.gnu.org; 28 Apr 2024 10:07:00 +0000 Received: from localhost ([127.0.0.1]:50123 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s11Qx-0004dn-N1 for submit@debbugs.gnu.org; Sun, 28 Apr 2024 06:07:00 -0400 Received: from mout01.posteo.de ([185.67.36.65]:45483) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s11Qv-0004dW-Df for 70597@debbugs.gnu.org; Sun, 28 Apr 2024 06:06:58 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id D7DDF240027 for <70597@debbugs.gnu.org>; Sun, 28 Apr 2024 12:06:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1714298791; bh=qgyQ47ToPRlsrlKmadsyE+51UPmX4X4+PY32qgN2PrA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=N3DstC4xYH4hNDp0pGISuxhlcY5XzCDf+mPcjb63KMVttOYTYTdaV5qOw/99RsosZ lC1JMt0csHa4fjpWyD4wUpRI/Qa3eXZEJOJfjze/x/q/dSNIGzlVWITCBtdcEmxCnq b7zFj9Tlg00nwGcSOdoYszUR7Y7KfJZCRnKNnvdGFaNmS6Sie9gBvgkLA1/DqlTNMS K0s8lmS3vO7vg8xNGHRiK6zfrceL4LepHjw+BvnKRl746MEdOQfl9Brrq4T3U7+RE4 IjylDmnTVre3f9Tk3QQjGfPtJ55sJsa8MKiOOmQO4y8arshZJN+9nf/d+fWE9Z+OkP ksPpWXlqxKnSg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4VS2DQ2dP3z9rxB; Sun, 28 Apr 2024 12:06:30 +0200 (CEST) From: Ihor Radchenko To: Bruno Barbier Subject: Re: bug#70597: Problem in pcase-let? In-Reply-To: <662e1e70.050a0220.3a3a2.45d1@mx.google.com> References: <662d23bf.050a0220.a4e2f.3f45@mx.google.com> <662e1e70.050a0220.3a3a2.45d1@mx.google.com> Date: Sun, 28 Apr 2024 10:07:28 +0000 Message-ID: <87frv5ls0v.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 70597 Cc: Marco Antoniotti , 70597@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Bruno Barbier writes: > So, you would prefer for pcase-let to always signal an error if a > pattern doesn't match. It makes sense. > > And it looks like the issue has already been raised: see bug#19670. > (see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19670) Also, see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=68509 -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 28 06:19:24 2024 Received: (at 70597) by debbugs.gnu.org; 28 Apr 2024 10:19:25 +0000 Received: from localhost ([127.0.0.1]:50133 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s11cy-0004oX-Kn for submit@debbugs.gnu.org; Sun, 28 Apr 2024 06:19:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50904) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s11cw-0004o7-1Z for 70597@debbugs.gnu.org; Sun, 28 Apr 2024 06:19:22 -0400 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 1s11cW-0008UQ-Fx; Sun, 28 Apr 2024 06:18:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=IQ2qBRRl6t3jE49dfkcKceoFoaubvk8ch4xD6EIkBR8=; b=kR1ctgOOU4vi +k88SQiKYj2DhzxtOp+gmvgOrsgQI0W1a948mvcv7iZw4wvf129ke+4Qjq1rkmqfdDV2r2eK/0pq7 sweINtkxEaJv/Y38IA1zAxmn5yAc9V7eZF3y93+mN2fqXrAiOzGrrG3OSrxq/Ke/foH2aybgAYzkd vp/0RRKcgYFw0xpJrIxjva9maGvFannr9w9hbTZFOv53Z334wZ6aP+CvXjg4O15oNYj8pF/uuOV/0 eVk9rbaklFVKLdIeyWbcsfDzZ6VOGZBnnyOpX3ov3s5mbsYP3H+xxYJDzpIee00x2Ql9/hwZ+IL7B p3bjvK3DD2UotY5l5Ys/BA==; Date: Sun, 28 Apr 2024 13:18:46 +0300 Message-Id: <86mspdu6wp.fsf@gnu.org> From: Eli Zaretskii To: Ihor Radchenko , Stefan Monnier In-Reply-To: <87frv5ls0v.fsf@localhost> (message from Ihor Radchenko on Sun, 28 Apr 2024 10:07:28 +0000) Subject: Re: bug#70597: Problem in pcase-let? References: <662d23bf.050a0220.a4e2f.3f45@mx.google.com> <662e1e70.050a0220.3a3a2.45d1@mx.google.com> <87frv5ls0v.fsf@localhost> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 70597 Cc: brubar.cs@gmail.com, marcoxa@gmail.com, 70597@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Cc: Marco Antoniotti , 70597@debbugs.gnu.org > From: Ihor Radchenko > Date: Sun, 28 Apr 2024 10:07:28 +0000 > > Bruno Barbier writes: > > > So, you would prefer for pcase-let to always signal an error if a > > pattern doesn't match. It makes sense. > > > > And it looks like the issue has already been raised: see bug#19670. > > (see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19670) > > Also, see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=68509 Adding Stefan, in case he has comments. From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 28 11:23:08 2024 Received: (at 70597) by debbugs.gnu.org; 28 Apr 2024 15:23:08 +0000 Received: from localhost ([127.0.0.1]:50757 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s16Mu-00007B-22 for submit@debbugs.gnu.org; Sun, 28 Apr 2024 11:23:08 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:40856) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s16Mr-00006B-AS for 70597@debbugs.gnu.org; Sun, 28 Apr 2024 11:23:06 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 1EE0510005D; Sun, 28 Apr 2024 11:22:40 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1714317759; bh=gsndjNMXZcu5vzD972ArjVmwn/PQ/gstol+9S03ffoU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=nNKqb+izjjd9OgQoYgZ/ldQGSN/HOdRUFDVm1IQzavbfZfoby9QAFkzTvB9TujPEY WDcFWsxmSuVBdqEUuAO8XGaIHsE3939SVWhA3QxpQ7TPMZ7wS0UVXuMWlbROqFUvx+ TMaj2HBX+LxbHPapeSZA9laWOvwFJVyAOFiQCuLwelq8X+2kpFmZbnDpaYWLAAoH88 R/Q4GvaTq09oZ+exQgm7zhL9Edi3xSLT3rFR1+feN2YoW9edKiws12Bibtn/b9RaEI QQfJRyWQ+xgbEqJc/KFswGXRppb9sY1tb3y6yEkKvYzH4kWafveNNTe18uaEUibUul 997FT2SlDz3Qw== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 1829E100035; Sun, 28 Apr 2024 11:22:39 -0400 (EDT) Received: from pastel (unknown [45.72.201.215]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id E465F120708; Sun, 28 Apr 2024 11:22:38 -0400 (EDT) From: Stefan Monnier To: Marco Antoniotti Subject: Re: bug#70597: Problem in pcase-let? In-Reply-To: (Marco Antoniotti's message of "Sun, 28 Apr 2024 00:28:41 +0200") Message-ID: References: <662d23bf.050a0220.a4e2f.3f45@mx.google.com> Date: Sun, 28 Apr 2024 11:22:37 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.038 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 70597 Cc: Bruno Barbier , 70597@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Pattern matchers do ... pattern matching. `pcase` is a pattern matcher. `pcase-let` is not: it performs "destructuring bindings". If you want to test if a pattern matches, then you want to use `pcase` or `pcase-exhaustive`, and not `pcase-let`. If you want a "one-branch `pcase-exhaustive` with a let-style notation", we could add such a thing of course, but I'd first like to see some evidence that it's useful in practice. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 28 11:39:08 2024 Received: (at 70597) by debbugs.gnu.org; 28 Apr 2024 15:39:08 +0000 Received: from localhost ([127.0.0.1]:50847 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s16cO-0000I2-Ch for submit@debbugs.gnu.org; Sun, 28 Apr 2024 11:39:08 -0400 Received: from mail-yb1-xb34.google.com ([2607:f8b0:4864:20::b34]:47309) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s16cN-0000Hh-35 for 70597@debbugs.gnu.org; Sun, 28 Apr 2024 11:39:07 -0400 Received: by mail-yb1-xb34.google.com with SMTP id 3f1490d57ef6-de54cb87998so3974335276.2 for <70597@debbugs.gnu.org>; Sun, 28 Apr 2024 08:38:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714318722; x=1714923522; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=QmaceAQF+6IWu/G3Y8gcQ+5+FRvW7pBcPeip8dY3SBg=; b=ZESKCWFVsZ+8lGs26cZp8unzJjs2tbwBFTG4A0kc2+1CCa8SWvaIr8WAj6YY5J0Hvx ltHLk6yYT3ouiafG+Ss7pIMYLMcorvQA3t+lQY3LbxBK+b+DAf0o4sggDRII6FKoBqLn VC+2JsmKqSkzcP3sdUvKf3H4CE4G1aeCOnAauaii89T5aCnVOqLKB6AKezCI1ipoRQ7O bYP9REdpF+AdtZvdGazJes1PTL3SeiFEaCEeKWERPy9jO5CIa7+glR6Ggb5L5WmjlEij aH87KTwU8W9JmRkya3wcW7Mpxbsnha+pZqnENfYlTUnn9U3oXhuknUcACP+9O+n/guMh nR4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714318722; x=1714923522; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=QmaceAQF+6IWu/G3Y8gcQ+5+FRvW7pBcPeip8dY3SBg=; b=hgMWI+1wuDUPBTyWVUfZtKYJ6kYLcVtj7EI4FAVuIUQoEpmTz/TY6t/L1vZXhELIwB eQJMMdr33ee3TEnkaB0eLuTQCa9zRHnMOiM/IZWjkR4rTgTbyaVRUf2mtQD42U8kBn+2 lhJ2KIGJUxRvSGz47M3rQAyCHEm4ZeZTQxElyjoFd2ouTj+oBnfzD1l58h5X6x3YMiJX 9+MXpNgJ8iGtxTu9+42ryb5+/BpKoH2WJ3blBV97GavzfRsardAQUnahKRIAJmDzGsVd FYFUxAigq2WASzY8z8U3E0Ua263HMppVMQRcjvN8cLhqQgF1d9BDFklecUghHl7NSek1 K/7w== X-Forwarded-Encrypted: i=1; AJvYcCU9RslgXMPs2sKkzpsucrraGbbmvkACqnmnt0DiO01bJesklA414Jor1MBJ249nf8FDaeD0pIpRXOrmMGiemk8/snivzEQ= X-Gm-Message-State: AOJu0YzjPg/6zcCplg2hZByJe8201ZA0UY5rbUxILXWuf6HRWRgz6cN3 82Xn8dLCXLJuHraovABwnaruzeJ71BO4a5Fdf21NQ0puRvAKb0pFBEe7t19LouEFPkyhi5Iv5P6 qtEq97CGsQLufK5hPI2kokIF6vaA= X-Google-Smtp-Source: AGHT+IFDCheado547Q/0h7p7Hi65WSQUb2Ec8Xnx7tTrrkP8q9m612GE+QRZHdkLW95aJVndspX8Wus8c2+5YWiNynk= X-Received: by 2002:a25:7447:0:b0:dd1:3421:b3ea with SMTP id p68-20020a257447000000b00dd13421b3eamr9091780ybc.21.1714318721811; Sun, 28 Apr 2024 08:38:41 -0700 (PDT) MIME-Version: 1.0 References: <662d23bf.050a0220.a4e2f.3f45@mx.google.com> In-Reply-To: From: Marco Antoniotti Date: Sun, 28 Apr 2024 17:38:30 +0200 Message-ID: Subject: Re: bug#70597: Problem in pcase-let? To: Stefan Monnier Content-Type: multipart/alternative; boundary="000000000000720ee9061729ee1b" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 70597 Cc: Bruno Barbier , 70597@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --000000000000720ee9061729ee1b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thank you all for the replies. Let me just answer the destructuring-bind comment by Stefan (I am answering to his last email). The previous ones are somewhat answered here as well. In some sense, yes. I kind of want destructuring-bind. It is, IMHO, unfortunate that ELisp does not have it and that we don't have cl-destructuring-bind either; lower level beast than matching, but useful. As per the pcase-let, I still think that the name and/or its behavior are confusing because of expectations about how a pattern matcher usually works. Of course you have the problems with "no matching" but that semantics can be dealt with separately, without surprising the user (at least me). And note that this is, IMHO, "surprising". *(pcase-let (`(foo bar ,x) '(bar foo 42)) x)* IMHO, this should either return nil or signal an error. With destructuring-bind* I would write (assuming indifference variables): *(destructuring-bind* (_ _ x) x)* All the best Marco On Sun, Apr 28, 2024 at 5:22=E2=80=AFPM Stefan Monnier wrote: > > Pattern matchers do ... pattern matching. > > `pcase` is a pattern matcher. > `pcase-let` is not: it performs "destructuring bindings". > > If you want to test if a pattern matches, then you want to use `pcase` > or `pcase-exhaustive`, and not `pcase-let`. > > If you want a "one-branch `pcase-exhaustive` with a let-style notation", > we could add such a thing of course, but I'd first like to see some > evidence that it's useful in practice. > > > Stefan > > --=20 Marco Antoniotti Somewhere over the Rainbow --000000000000720ee9061729ee1b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thank you all for the replies.

Let me just answer the destructuring= -bind comment by Stefan (I am answering to his last email).=C2=A0 Th= e previous ones are somewhat answered here as well.

In some se= nse, yes.=C2=A0 I kind of want destru= cturing-bind.=C2=A0 It is, IMHO, unfortunate that ELisp does not hav= e it and that we don't have cl-de= structuring-bind either; lower level beast than matching, but useful= .

As per the pcase-= let, I still think that the name and/or its behavior are confusing b= ecause of expectations about how a pattern matcher usually works.=C2=A0 Of = course you have the problems with "no matching" but that semantic= s can be dealt with separately, without surprising the user (at least me).= =C2=A0 And note that this is, IMHO, "surprising".

(pcase-let (`(foo bar ,x) '(bar f= oo 42)) x)

IMHO, this should either return= nil or signal an error.=C2=A0= With=C2=A0destructuring-bind*= I would write (assuming indifference variables):

(destructuring-bind* (_ _ x) x)
All the best

Marco

On Sun, Apr 28, 2024 at 5:22=E2=80=AFPM Stefan Monnier <monnier@iro.umontreal.ca> wrote= :
> Pattern m= atchers do ... pattern matching.

`pcase` is a pattern matcher.
`pcase-let` is not: it performs "destructuring bindings".

If you want to test if a pattern matches, then you want to use `pcase`
or `pcase-exhaustive`, and not `pcase-let`.

If you want a "one-branch `pcase-exhaustive` with a let-style notation= ",
we could add such a thing of course, but I'd first like to see some
evidence that it's useful in practice.


=C2=A0 =C2=A0 =C2=A0 =C2=A0 Stefan



--
Marco Antonio= tti
Somewhere over the Rainbow
--000000000000720ee9061729ee1b-- From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 28 13:05:56 2024 Received: (at 70597) by debbugs.gnu.org; 28 Apr 2024 17:05:56 +0000 Received: from localhost ([127.0.0.1]:51255 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s17yO-0001Pl-Da for submit@debbugs.gnu.org; Sun, 28 Apr 2024 13:05:56 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:10175) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s17yM-0001Pb-09 for 70597@debbugs.gnu.org; Sun, 28 Apr 2024 13:05:55 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 7434480CE1; Sun, 28 Apr 2024 13:05:28 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1714323927; bh=LM/KOP/NBuhBsPEXEu4uhPddjbxfSvamc7yMgPvQjxA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=YoCp/d166KZKblqWjIKSzrUjTzB9ufDLnMsEHCrqwEdqgHFy4aYPJ6t/ILTPzwQGE ErvJd58WHuH59W2zHzypdywDINiBruAg4T8Eej6KD7IW2Mdq/zSdguVs/lyM/M53Vo KNEoLRIOwBNYSsYmz3YmjCUug/7cO0Oc4tj03mstGq8MqQGxrnzrFKyZth09HweKOC UHJ+Xd/LHjRvxxYRBN/6jDK/O93eRX/uYQ/Wf7Sdps7FqzfbenlNzKWJWYoWcgo9vH Mkh+vvLxzsBEApG52azRzX0FCKObh+pduSvb6XDvFQ1CHD4Mz6CAj4tAJ/jkPgegCi 3X5LgTT9L9xpQ== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 66E99806AA; Sun, 28 Apr 2024 13:05:27 -0400 (EDT) Received: from pastel (unknown [45.72.201.215]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 3E9CA12030C; Sun, 28 Apr 2024 13:05:26 -0400 (EDT) From: Stefan Monnier To: Marco Antoniotti Subject: Re: bug#70597: Problem in pcase-let? In-Reply-To: (Marco Antoniotti's message of "Sun, 28 Apr 2024 17:38:30 +0200") Message-ID: References: <662d23bf.050a0220.a4e2f.3f45@mx.google.com> Date: Sun, 28 Apr 2024 13:05:26 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.052 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 70597 Cc: Bruno Barbier , 70597@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Let me just answer the destructuring-bind comment by Stefan (I am answering > to his last email). The previous ones are somewhat answered here as well. > > In some sense, yes. I kind of want destructuring-bind. It is, IMHO, > unfortunate that ELisp does not have it and that we don't have > cl-destructuring-bind either; lower level beast than matching, but useful. I don't understand what you mean: `pcase-let` *is* a destructring bind, and we also do have `cl-destructuring-bind`. > As per the pcase-let, I still think that the name and/or its behavior > are confusing because of expectations about how a pattern matcher > usually works. Yes, clearly there is a problem of users being surprised. But AFAICT, changing the semantics is not the right answer, because the current behavior matches(!) what is usually needed and because the other behaviors are already well-served by `pcase` and `pcase-exhaustive`. Maybe a better answer is to try and detect ill-conceived patterns like in: (pcase-let (`(foo bar ,x) (SOMETHING)) (ANYTHING)) and emit a warning suggesting to rewrite it to (pcase-let (`(,_ ,_ ,x) (SOMETHING)) (ANYTHING)) - Stefan From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 28 14:23:06 2024 Received: (at 70597) by debbugs.gnu.org; 28 Apr 2024 18:23:06 +0000 Received: from localhost ([127.0.0.1]:51590 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s19B4-0005DO-BT for submit@debbugs.gnu.org; Sun, 28 Apr 2024 14:23:06 -0400 Received: from mail-yw1-x1129.google.com ([2607:f8b0:4864:20::1129]:59402) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s19B2-0005Cz-1z for 70597@debbugs.gnu.org; Sun, 28 Apr 2024 14:23:04 -0400 Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-61b6200fcb5so39328397b3.2 for <70597@debbugs.gnu.org>; Sun, 28 Apr 2024 11:22:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714328559; x=1714933359; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=S/++dPZ6Yga5M9GM5mXpG3kmgqzX7y2irj/qxy93cFQ=; b=bBcd/z7nxAFMefL3w1WSPzWjBT1Ek0cVXlDMIeMDht62RjQD6/vTbWYl0B7HImqP+8 zmw3nqzW4kxAS5uuHgs2Ci1D6pSYHVPGBjpXd9e1twCPdUb7Mr706J4p59Wl5CALVgZX yK6iISzi+EoPjjRnT7nODrjLcO/u1kj76VvqlYELXXq+7gMCL+56o1LuCefb2GN4PdwG YApCRM7UbMCJSoiGf4eZ61oOgOGuM9bl+dDV48UuDZj2MKZr5wTChfKDMlC82AC1W2z4 9RUpqedlZLbsVZ0fyvyTSpcWFPg8bYsfDzzY7MGleR3gkuWStOKQFwM/YLoFTWm7zJSt 3R9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714328559; x=1714933359; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=S/++dPZ6Yga5M9GM5mXpG3kmgqzX7y2irj/qxy93cFQ=; b=n4In1mfZ+vCAV4QEV9WxenyBY6tXeCldFPEzO30JgW7gxJoZ+VGbrLsaiFgPWL2CUo Y9XQaT9UVHLmL1j09J18/gbBvn3zuPMru5HdGr3T8YlBjGnRK28lqg7ya8WAXuhIbjxk JdpRCm47vmaHX6oQskWKPIMAfTjxxhD5QvgE2CZyuiKpPg4ODjF6kIm5NaTqp8KKfSVH x3sdlULU6XyXwRp9+1Oa7zdE+FpnqbC45F4mm/RA3orKbnPJ6HjgQOWmeQLb+L+yZM5s Md5/koVVyXg3RMvhJsoSMtGViUXtjOP7+jpWuaTTaLYCOxNQWDzXoAfNT68C5zX8zQCi cgsg== X-Forwarded-Encrypted: i=1; AJvYcCXrAhw4HgOIGsqU1DY99bA13tcgZpjwKd9ejQeZuij+QTPrgqaJfLP8asHhS4T4VkoM9SYMkcHncl2qshUyxHCKWlDgoGw= X-Gm-Message-State: AOJu0Yw8PGhIgB2BB49+Ipl2BaZkm04h61BzliBdkncqvgZZWKnVNOJG qTI7nZ/mzepn/vtquB/BSTFEvpqB9M9Hi9mp9b85IzfYlv77qXnp9FJszwoh0mWj6eJj0n0MMRU AP4XieRgyYBh0VPePg4VKmQjegO45rmEl X-Google-Smtp-Source: AGHT+IHYgAAOEHDSSNYKxbQGkU9HNO2GNasw9zOJfJypmDnAj+I6MFV/+5g1l8NH/oLe0QOgvrivrgGG/LU3JDT/TrU= X-Received: by 2002:a05:690c:f88:b0:61a:d455:3dc6 with SMTP id df8-20020a05690c0f8800b0061ad4553dc6mr10610521ywb.11.1714328558747; Sun, 28 Apr 2024 11:22:38 -0700 (PDT) MIME-Version: 1.0 References: <662d23bf.050a0220.a4e2f.3f45@mx.google.com> In-Reply-To: From: Marco Antoniotti Date: Sun, 28 Apr 2024 20:22:27 +0200 Message-ID: Subject: Re: bug#70597: Problem in pcase-let? To: Stefan Monnier Content-Type: multipart/alternative; boundary="000000000000c5c85006172c38a7" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 70597 Cc: Bruno Barbier , 70597@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --000000000000c5c85006172c38a7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi oooops sorry. Somehow I was missing cl-destructuring-bind; my bad. In any case, at a minimum the warning should be issued. I did refrain from using pcase-let after all, although it "seemed right" for my use case. Having said that, I would advocate changing the semantics. Your call anyway. All the best On Sun, Apr 28, 2024 at 7:05=E2=80=AFPM Stefan Monnier wrote: > > Let me just answer the destructuring-bind comment by Stefan (I am > answering > > to his last email). The previous ones are somewhat answered here as > well. > > > > In some sense, yes. I kind of want destructuring-bind. It is, IMHO, > > unfortunate that ELisp does not have it and that we don't have > > cl-destructuring-bind either; lower level beast than matching, but > useful. > > I don't understand what you mean: `pcase-let` *is* a destructring bind, > and we also do have `cl-destructuring-bind`. > > > As per the pcase-let, I still think that the name and/or its behavior > > are confusing because of expectations about how a pattern matcher > > usually works. > > Yes, clearly there is a problem of users being surprised. > > But AFAICT, changing the semantics is not the right answer, because the > current behavior matches(!) what is usually needed and because the other > behaviors are already well-served by `pcase` and `pcase-exhaustive`. > > Maybe a better answer is to try and detect ill-conceived patterns like in= : > > (pcase-let (`(foo bar ,x) (SOMETHING)) (ANYTHING)) > > and emit a warning suggesting to rewrite it to > > (pcase-let (`(,_ ,_ ,x) (SOMETHING)) (ANYTHING)) > > > - Stefan > > --=20 Marco Antoniotti Somewhere over the Rainbow --000000000000c5c85006172c38a7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

oooops sorry.=C2=A0 Someh= ow I was missing cl-destructuring-bin= d; my bad.

In any case, at a minimum th= e warning should be issued.=C2=A0 I did refrain from using pcase-let after all, although it "seemed = right" for my use case.=C2=A0 Having said that, I would advocate chang= ing the semantics.

Your call anyway.

All the best

On Sun, Apr 28, 2024 at 7:05=E2=80=AFPM Stef= an Monnier <monnier@iro.umon= treal.ca> wrote:
> Let me just answer the destructuring-bind comment by Stefan (I= am answering
> to his last email).=C2=A0 The previous ones are somewhat answered here= as well.
>
> In some sense, yes.=C2=A0 I kind of want destructuring-bind.=C2=A0 It = is, IMHO,
> unfortunate that ELisp does not have it and that we don't have
> cl-destructuring-bind either; lower level beast than matching, but use= ful.

I don't understand what you mean: `pcase-let` *is* a destructring bind,=
and we also do have `cl-destructuring-bind`.

> As per the pcase-let, I still think that the name and/or its behavior<= br> > are confusing because of expectations about how a pattern matcher
> usually works.

Yes, clearly there is a problem of users being surprised.

But AFAICT, changing the semantics is not the right answer, because the
current behavior matches(!) what is usually needed and because the other behaviors are already well-served by `pcase` and `pcase-exhaustive`.

Maybe a better answer is to try and detect ill-conceived patterns like in:<= br>
=C2=A0 =C2=A0 (pcase-let (`(foo bar ,x) (SOMETHING)) (ANYTHING))

and emit a warning suggesting to rewrite it to

=C2=A0 =C2=A0 (pcase-let (`(,_ ,_ ,x) (SOMETHING)) (ANYTHING))


- Stefan



--
Marco Antonio= tti
Somewhere over the Rainbow
--000000000000c5c85006172c38a7-- From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 28 17:08:57 2024 Received: (at 70597) by debbugs.gnu.org; 28 Apr 2024 21:08:57 +0000 Received: from localhost ([127.0.0.1]:52885 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s1BlZ-00027a-2Y for submit@debbugs.gnu.org; Sun, 28 Apr 2024 17:08:57 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:57398) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s1BlX-00027U-E6 for 70597@debbugs.gnu.org; Sun, 28 Apr 2024 17:08:56 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id B5F34442206; Sun, 28 Apr 2024 17:08:29 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1714338508; bh=Lz7++8UD7fUjExjnloNPxWbyGoe1AGBllmMDpmbohYg=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=fSVVW8VYh6czFLVxduufEATmNgJoezDNaj2LCELo3pOBZ3QEsSrK9O4ZPWUipDBj0 u8KwIay0EMDa6QA737q8Bs2u3VtemdHstbNRRX//6qQHY+W5XhLmBMtj5tLi5abTZx ycEtMs5SXfZKATLNO7iJ52pU0hT5wkGJkkK8CmYGCqA/nGpWPv2D5ogpWMCN4XTzIQ XBT+YiDAh3P/5Eud2xCmAGPi4r8bjTLB+vLINbjPfpkm+dvtKAUKUo+ladXuqC2EH5 qFQHmhXmtNLW38cs5N2rNiypFVgNq9d2mFKONI02bwa2mEH4ZLrRVOKPH1KNpLcwPf M9m8XRmBMBwTg== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 90E48442204; Sun, 28 Apr 2024 17:08:28 -0400 (EDT) Received: from pastel (unknown [45.72.201.215]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 66CCA120306; Sun, 28 Apr 2024 17:08:28 -0400 (EDT) From: Stefan Monnier To: Marco Antoniotti Subject: Re: bug#70597: Problem in pcase-let? In-Reply-To: (Marco Antoniotti's message of "Sun, 28 Apr 2024 20:22:27 +0200") Message-ID: References: <662d23bf.050a0220.a4e2f.3f45@mx.google.com> Date: Sun, 28 Apr 2024 17:08:21 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.007 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 70597 Cc: Bruno Barbier , 70597@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > In any case, at a minimum the warning should be issued. I haven't looked at the code for it, so I don't know how easy it is to implement, but let' hope there's an "easy" way to do it. > I did refrain from using pcase-let after all, although it "seemed > right" for my use case. Having said that, I would advocate changing > the semantics. The places that already use it largely rely on the current semantics, so changing it would introduce a lot of breakage. It's not really an option. Stefan From debbugs-submit-bounces@debbugs.gnu.org Thu May 02 05:24:31 2024 Received: (at 70597) by debbugs.gnu.org; 2 May 2024 09:24:31 +0000 Received: from localhost ([127.0.0.1]:42614 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s2Sg2-0005xK-NR for submit@debbugs.gnu.org; Thu, 02 May 2024 05:24:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43768) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s2Sg0-0005xB-Rq for 70597@debbugs.gnu.org; Thu, 02 May 2024 05:24:29 -0400 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 1s2SfX-000460-Q6; Thu, 02 May 2024 05:23:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=7abEfXmOpXIeJgcTdRRZHY7ADwVHD39LWnKbowplVl0=; b=a2d4ktTB7ccg GSFCXYZp9I1DRdxBMfGwRWgSAHueQ0rWHCspQ0rnKuV1qk20JtJ27vsYiCwCEXAwf0cgPPpkkDgw0 HrZigqh5F239292ARoYij8+q+YaCQMlqhm52fPRSwxMI842kBj/pbu8hUnL0O0c2xBUp/nRqOon/P vxmg1DkKra60pe1tyqHCp5nWuLjAnL7HbgUi2v6k0rCOIW+aiMrut1nXoBzSs5kCGH4nkznajN+xL V42Qo5XKaMvvsvYzB3fVrRHO+h0LbZUW2ANjpwV/87/Mgi6epffloPY7CCvqU3Ub41lnGkbc1yYoG DMAYu7QU14pid7sbd7Dvow==; Date: Thu, 02 May 2024 12:23:57 +0300 Message-Id: <865xvwmus2.fsf@gnu.org> From: Eli Zaretskii To: Stefan Monnier In-Reply-To: (bug-gnu-emacs@gnu.org) Subject: Re: bug#70597: Problem in pcase-let? References: <662d23bf.050a0220.a4e2f.3f45@mx.google.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 70597 Cc: brubar.cs@gmail.com, marcoxa@gmail.com, 70597@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Cc: Bruno Barbier , 70597@debbugs.gnu.org > Date: Sun, 28 Apr 2024 17:08:21 -0400 > From: Stefan Monnier via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > > In any case, at a minimum the warning should be issued. > > I haven't looked at the code for it, so I don't know how easy it is to > implement, but let' hope there's an "easy" way to do it. > > > I did refrain from using pcase-let after all, although it "seemed > > right" for my use case. Having said that, I would advocate changing > > the semantics. > > The places that already use it largely rely on the current semantics, > so changing it would introduce a lot of breakage. > It's not really an option. So I guess we should close this as wontfix? From debbugs-submit-bounces@debbugs.gnu.org Thu May 02 07:07:39 2024 Received: (at 70597) by debbugs.gnu.org; 2 May 2024 11:07:39 +0000 Received: from localhost ([127.0.0.1]:43114 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s2UHq-00075L-Oj for submit@debbugs.gnu.org; Thu, 02 May 2024 07:07:39 -0400 Received: from mail-yb1-xb36.google.com ([2607:f8b0:4864:20::b36]:61589) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s2UHp-000759-A5 for 70597@debbugs.gnu.org; Thu, 02 May 2024 07:07:37 -0400 Received: by mail-yb1-xb36.google.com with SMTP id 3f1490d57ef6-de610800da0so3311339276.2 for <70597@debbugs.gnu.org>; Thu, 02 May 2024 04:07:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714648030; x=1715252830; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=q7Z0QhMFLE8t+MY0QgkujX3GZRw4SKmyn0R0WWQb6yw=; b=Ofh6N2jpLXA+dGNMGdV5qXBf4oim82qhUkyljnncDgtCHCJVeg4MuOjPFnonRFiLpB 6s/CuVGqZNWmvwru3R3MMKdk/AbdyoNTeF6bW5oQ1JrqPX2DzmtuGvtD0PJqAlkzBumH LgLmUMyPbrr4zIzIs9lFCO+7VzNKQIZyFzLAINID1tQeTF+2IznQmvWUqW2pHm+DOFey zWdb3SJS1NM3vvxmUL8pACfmFrCAH6IdDeUzKqEgURieksHyuhacnTB09HW4ke/xn6n6 NnZjOOizhinhqz6kYrdJcdVzKcNc7OGCYPfvogzQRfWXjKZhqigBLMqbvyfgsKiacnH6 cWNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714648030; x=1715252830; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=q7Z0QhMFLE8t+MY0QgkujX3GZRw4SKmyn0R0WWQb6yw=; b=Pslx70hlWXN2mMp1gIPDIuCYdaKQfgl7UAhr+UDqlTxAzWnpokVGxBKertqNGIfRW5 qIfZlAdU3q26yxfDHMvKTVGGS41AlSqoXxOtDBNhkpR1ILJknw5RSReJqBL3a3wRVD6P St6J81nti4s4vLgW1mbIIWI4mDSI6cU9b5NjD51sol4dMGsrYcrS9jzo611QuVTVlS8P vFJNjxpc8ju1eiAVk9bXoUKTahyoZZN/FeKzDMrxQGK+K5FkjG11dx1XD/Dv5sy/XV6d zscQOIAdWxEEXhNoeS5/8gzmGfc64o92uTxiiztyjoVJoc8H9ei7LVzOca34efzwki2w dHtw== X-Forwarded-Encrypted: i=1; AJvYcCV0dZGN1LyUsz7GH4uusFc9xxFIom1jwt1DQ5XmEdG81wd+A+1vTO4J/uT0p6Bnmw0pc6exP0ymiT1kvQcMi9q6vqjxUSs= X-Gm-Message-State: AOJu0YyZOTvuq60LhCpbO0aOr4QqS4dfJgV060MtBH9BOoNMTrakheug iPtn8/ZPXSRSjRqMAi9cCUUkAMBnQzaxzJJcP8B3oqi3NYpXQ3FulSM9fbDUjaX5zTd+r6zhp2G 2eOhSC/SE/5lMhc2heYXfzNqvwE4= X-Google-Smtp-Source: AGHT+IHYf4+NK+xupQmM8azY18OHaLW+E3r3JaYsOrrwuGpCXfQqX3i9Y73p08Cp8Ugjpc5uPLxnL11NLkS6kWB36h0= X-Received: by 2002:a25:ae4c:0:b0:de4:5f9a:157a with SMTP id g12-20020a25ae4c000000b00de45f9a157amr1807441ybe.36.1714648029688; Thu, 02 May 2024 04:07:09 -0700 (PDT) MIME-Version: 1.0 References: <662d23bf.050a0220.a4e2f.3f45@mx.google.com> <865xvwmus2.fsf@gnu.org> In-Reply-To: <865xvwmus2.fsf@gnu.org> From: Marco Antoniotti Date: Thu, 2 May 2024 13:06:58 +0200 Message-ID: Subject: Re: bug#70597: Problem in pcase-let? To: Eli Zaretskii Content-Type: multipart/alternative; boundary="000000000000b9823c0617769ac0" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 70597 Cc: brubar.cs@gmail.com, Stefan Monnier , 70597@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --000000000000b9823c0617769ac0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi guys, it's your call. But please change the doc string to clarify that pcase-let does not do "symbol equality" pattern matching, but only structural matching. Adding an example like the following will help. (pcase-let ((`(foo ,x 23 ,y) '(bar 11 baz 22))) (list x y)) All the best Marco On Thu, May 2, 2024 at 11:24=E2=80=AFAM Eli Zaretskii wrote: > > Cc: Bruno Barbier , 70597@debbugs.gnu.org > > Date: Sun, 28 Apr 2024 17:08:21 -0400 > > From: Stefan Monnier via "Bug reports for GNU Emacs, > > the Swiss army knife of text editors" > > > > > In any case, at a minimum the warning should be issued. > > > > I haven't looked at the code for it, so I don't know how easy it is to > > implement, but let' hope there's an "easy" way to do it. > > > > > I did refrain from using pcase-let after all, although it "seemed > > > right" for my use case. Having said that, I would advocate changing > > > the semantics. > > > > The places that already use it largely rely on the current semantics, > > so changing it would introduce a lot of breakage. > > It's not really an option. > > So I guess we should close this as wontfix? > --=20 Marco Antoniotti Somewhere over the Rainbow --000000000000b9823c0617769ac0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi guys,

it's your call.= =C2=A0 But please change the doc string to clarify that pcase-let does not do "symbol equality"= pattern matching, but only structural matching.=C2=A0 Adding an example li= ke the following will help.

(pcase-let ((`(foo ,x 23 ,y) '(bar 11 baz= 22))) (list x y))

All the best
=

Marco

On Thu, May 2, 2024 at 11:24=E2=80=AFAM = Eli Zaretskii <eliz@gnu.org> wrot= e:
> Cc: Brun= o Barbier <brub= ar.cs@gmail.com>, 70597@debbugs.gnu.org
> Date: Sun, 28 Apr 2024 17:08:21 -0400
> From:=C2=A0 Stefan Monnier via "Bug reports for GNU Emacs,
>=C2=A0 the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>
> > In any case, at a minimum the warning should be issued.
>
> I haven't looked at the code for it, so I don't know how easy = it is to
> implement, but let' hope there's an "easy" way to do= it.
>
> > I did refrain from using pcase-let after all, although it "s= eemed
> > right" for my use case.=C2=A0 Having said that, I would advo= cate changing
> > the semantics.
>
> The places that already use it largely rely on the current semantics,<= br> > so changing it would introduce a lot of breakage.
> It's not really an option.

So I guess we should close this as wontfix?


--
Marco Antonio= tti
Somewhere over the Rainbow
--000000000000b9823c0617769ac0-- From debbugs-submit-bounces@debbugs.gnu.org Sat May 04 07:36:25 2024 Received: (at 70597-done) by debbugs.gnu.org; 4 May 2024 11:36:25 +0000 Received: from localhost ([127.0.0.1]:52859 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s3Dgl-0004Ka-5z for submit@debbugs.gnu.org; Sat, 04 May 2024 07:36:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38904) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s3Dgg-0004KP-Rf for 70597-done@debbugs.gnu.org; Sat, 04 May 2024 07:36:22 -0400 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 1s3DgB-00063U-Lh; Sat, 04 May 2024 07:35:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=WkMlILNgnj5zFJNd5xiMMokzKCqAUU91w/B/ui3Lc0E=; b=GkuuluC8H3bK j/F3NQIQqLQUMLll+rftT0XNL0TiZwReyn6NL8fECWygOupAVfKe4QLIqSFXhBIWFOvBGPQQbF7wj 24SGLNcF1MR4pf2qtN2604S2AjEv/RIiTXrt9PvNcr73Rx9qQg3e3xfMYm8SjZkzWw/2B8FMtrSRl +UfuLP9RS8WmnehSZvMRVJuUBz9X3jaO8Yi+Xl/e4JpHPHRMYSQTRHe9W/0b5FtxUSRzCm8ciTsS/ 3jk/ocQBs7eUUe5B5aMOq/sfuBC1yl8ChHFVXlupyxwjMxNLTYNBH2GjbxDrBultdBQ4UWIT0Z5KT kKaVpokk68DDZqWTJ/D+vQ==; Date: Sat, 04 May 2024 14:35:43 +0300 Message-Id: <861q6hhks0.fsf@gnu.org> From: Eli Zaretskii To: Marco Antoniotti In-Reply-To: (message from Marco Antoniotti on Thu, 2 May 2024 13:06:58 +0200) Subject: Re: bug#70597: Problem in pcase-let? References: <662d23bf.050a0220.a4e2f.3f45@mx.google.com> <865xvwmus2.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 70597-done Cc: brubar.cs@gmail.com, monnier@iro.umontreal.ca, 70597-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Marco Antoniotti > Date: Thu, 2 May 2024 13:06:58 +0200 > Cc: Stefan Monnier , brubar.cs@gmail.com, 70597@debbugs.gnu.org > > it's your call. But please change the doc string to clarify that pcase-let does not do "symbol equality" pattern > matching, but only structural matching. Adding an example like the following will help. > > (pcase-let ((`(foo ,x 23 ,y) '(bar 11 baz 22))) (list x y)) This is already explained in the ELisp manual, and the doc string already says Each EXP should match its respective PATTERN (i.e. be of structure compatible to PATTERN) So I don't think we need to do anything else here, and I'm closing this bug. From debbugs-submit-bounces@debbugs.gnu.org Sat May 04 08:07:30 2024 Received: (at 70597-done) by debbugs.gnu.org; 4 May 2024 12:07:30 +0000 Received: from localhost ([127.0.0.1]:53403 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s3EAs-0007sk-3U for submit@debbugs.gnu.org; Sat, 04 May 2024 08:07:30 -0400 Received: from mail-yb1-xb30.google.com ([2607:f8b0:4864:20::b30]:56386) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s3EAn-0007sX-Vg for 70597-done@debbugs.gnu.org; Sat, 04 May 2024 08:07:28 -0400 Received: by mail-yb1-xb30.google.com with SMTP id 3f1490d57ef6-de5b1e6beceso574835276.0 for <70597-done@debbugs.gnu.org>; Sat, 04 May 2024 05:07:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714824417; x=1715429217; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=kvEkuyPWRK8AtL/fxOGroJ22b/Th2A6E9LK8nNHpbT0=; b=gIWJv0sUkGACZ5D1aAE+Xl/+X3j6c7bY/+PdQimkWRyAlOKFBgLaOYR7mg0Q6xaQeQ SfoV27Do4USzgxFrtjpdyTISfVPCFpx56p9dx/0NdlU5o8gHuM6fX83qEPfNbo1VjMrQ H8fC09AJ3lDLYxFG/Iv8x5fFnXAzn9ud2HXQjJv4SY3zmhFRti4gEApEKbeVHse5XOP7 kxqjXTdN1hu7HS5ELbSpQ9ljm/CBkELhK5GlJlX4Kbak0C5PDWEwY9eS5cnWV489YB6s 2NEqlSc1JYjXAtQgipe/cXOt1QhmWCtHerC8m7Uwa5fsrS4leMbbns9d/G56R6JXmUQX Ilyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714824417; x=1715429217; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=kvEkuyPWRK8AtL/fxOGroJ22b/Th2A6E9LK8nNHpbT0=; b=XBeD7pojxgMSip/8wSq49BSbQgYsDF5BkvhsSwqU6sD1qTqeg7LmyflR1/e/a//2Ye YbJPgzzMPlPygMMrZ2q2G3h7YkHCMEXDCWOrMYAHVQOvY+nh6UNFa5B8aApwfU7cF0RN ZovGTytQ7HuInU5xKdbYU1tEAFoxOOrtIf+fxobpwBL70iGTyQLD6wVQV2DOakaSxddx 8HYuziH2fmpYn6UVPpaznTE1uV0wtfU+C3R6FM8TmXUw9GMg/bWzhWxgn+RsrAruVpRy r8Xn5muZlmBqc/MIXbHXj1qQiLt2xhJbuk5xAAhWpi8p7sVu6r/TqKj4hDXUFJJ2zceR n9oQ== X-Forwarded-Encrypted: i=1; AJvYcCXz6ck7Z/H+dUW4fubBzH0SZlv7YOG7UWO7XY6MgKccvH2ZHrnHFHs9CCUXPCMhPQmDj0Wc0/GGf5bJdLVbEzhJNXO6gbNPvT4HDw== X-Gm-Message-State: AOJu0YzBHi0kobQ6YsBaGMVBJfztvNl9l0aeqsLaPLwKGpih6sv8PhjK 7zGKzAH6p5LJTy24KnxFmPMX407o4U+dbtHDYKT1t7Nup72sOjnJQOg3dfbhkJ639EVCjWB3aMK CAwWDeMkMn5y4Z5Tgpdes0D5AcmQ= X-Google-Smtp-Source: AGHT+IEOLtftvHFIZKDaegXXX+J4IZ3Oyvr0RWkIbhUUUItelbANDzNWHA4KZT7qr1xmzekyUXEMr0AkmJ+Gwym/+ME= X-Received: by 2002:a25:3624:0:b0:de5:53c0:b9e5 with SMTP id d36-20020a253624000000b00de553c0b9e5mr5631814yba.40.1714824417237; Sat, 04 May 2024 05:06:57 -0700 (PDT) MIME-Version: 1.0 References: <662d23bf.050a0220.a4e2f.3f45@mx.google.com> <865xvwmus2.fsf@gnu.org> <861q6hhks0.fsf@gnu.org> In-Reply-To: <861q6hhks0.fsf@gnu.org> From: Marco Antoniotti Date: Sat, 4 May 2024 14:06:45 +0200 Message-ID: Subject: Re: bug#70597: Problem in pcase-let? To: Eli Zaretskii Content-Type: multipart/alternative; boundary="0000000000003de35b06179fac33" X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 70597-done Cc: brubar.cs@gmail.com, monnier@iro.umontreal.ca, 70597-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --0000000000003de35b06179fac33 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi sorry, but I do not think that the current doc string and/or the manual explains the situation. And it looks like this is a recurring misunderstanding by the users. Just adding the example would clarify things. All the best MA On Sat, May 4, 2024 at 1:35=E2=80=AFPM Eli Zaretskii wrote: > > From: Marco Antoniotti > > Date: Thu, 2 May 2024 13:06:58 +0200 > > Cc: Stefan Monnier , brubar.cs@gmail.com, > 70597@debbugs.gnu.org > > > > it's your call. But please change the doc string to clarify that > pcase-let does not do "symbol equality" pattern > > matching, but only structural matching. Adding an example like the > following will help. > > > > (pcase-let ((`(foo ,x 23 ,y) '(bar 11 baz 22))) (list x y)) > > This is already explained in the ELisp manual, and the doc string > already says > > Each EXP should match its respective PATTERN (i.e. be of structure > compatible to PATTERN) > > So I don't think we need to do anything else here, and I'm closing > this bug. > --=20 Marco Antoniotti Somewhere over the Rainbow --0000000000003de35b06179fac33 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

sorry, but I do not think that t= he current doc string and/or the manual explains the situation.

And it looks like this is a recurring misunderstanding by the users.=

Just adding the example would clarify things.

All the best

MA

On Sat, May 4, 2024 at 1:35=E2=80=AFPM Eli Zaretskii <eliz@gnu.org> wrote:
> From: Marco Antoniotti <marcoxa@gmail.com> > Date: Thu, 2 May 2024 13:06:58 +0200
> Cc: Stefan Monnier <monnier@iro.umontreal.ca>, brubar.cs@gmail.com, 70597@debbugs.gnu.org
>
> it's your call.=C2=A0 But please change the doc string to clarify = that pcase-let does not do "symbol equality" pattern
> matching, but only structural matching.=C2=A0 Adding an example like t= he following will help.
>
> (pcase-let ((`(foo ,x 23 ,y) '(bar 11 baz 22))) (list x y))

This is already explained in the ELisp manual, and the doc string
already says

=C2=A0 Each EXP should match its respective PATTERN (i.e. be of structure =C2=A0 compatible to PATTERN)

So I don't think we need to do anything else here, and I'm closing<= br> this bug.


--
Marco Antonio= tti
Somewhere over the Rainbow
--0000000000003de35b06179fac33-- From debbugs-submit-bounces@debbugs.gnu.org Sat May 04 11:05:49 2024 Received: (at 70597-done) by debbugs.gnu.org; 4 May 2024 15:05:49 +0000 Received: from localhost ([127.0.0.1]:54171 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s3GxQ-0001o7-QZ for submit@debbugs.gnu.org; Sat, 04 May 2024 11:05:49 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:5777) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s3GxO-0001nz-4A for 70597-done@debbugs.gnu.org; Sat, 04 May 2024 11:05:46 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id A5DAE80919; Sat, 4 May 2024 11:05:17 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1714835116; bh=l0WA9NKXq8G3DNz5J9/cYQi0yjfY2eezrxnsUwcQSi8=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=nHwa39hRC05DmpGSPv7xEF6Hw7jWcyahTek6YkOPp/xkKWHUUi8CDfgeTPIcks5Eg GSQ/5D5xPqQSNhiAJTm1K4dSRrOSpxXyJyXm2qLCGm86nueixVucHFeyFcL37Y2+yg PxW0gTYzDzfRgsN8wxzmwo9A941uBTwzZ5BK2XiGexS0d3gQ75AZ49pWup7Sp403PE QGd3fpZjD1fC2YjrqAuh/38cIz3+KMUHbv/DWZgjkGYDfx3M3SPtiazfgJlG41m2+5 Siw+K8MZmC0CZSLX8t+hui3bAMRAGW2hFIHQ/zE7Mq1iMRgjm+kazOxwfBq0lsxA2H 99rlRXDg96bRg== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 3FCB280013; Sat, 4 May 2024 11:05:16 -0400 (EDT) Received: from pastel (unknown [45.72.201.215]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 110AC12032D; Sat, 4 May 2024 11:05:16 -0400 (EDT) From: Stefan Monnier To: Marco Antoniotti Subject: Re: bug#70597: Problem in pcase-let? In-Reply-To: (Marco Antoniotti's message of "Sat, 4 May 2024 14:06:45 +0200") Message-ID: References: <662d23bf.050a0220.a4e2f.3f45@mx.google.com> <865xvwmus2.fsf@gnu.org> <861q6hhks0.fsf@gnu.org> Date: Sat, 04 May 2024 11:05:15 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.044 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 70597-done Cc: brubar.cs@gmail.com, Eli Zaretskii , 70597-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > sorry, but I do not think that the current doc string and/or the > manual explains the situation. Which "current" are you referring to? The "current" manual (in `master`) has a whole section on "Destructuring with pcase pattern" (see below). Do you still see room for misunderstanding there? If so, can you suggest how to change it to make it more clear? Stefan @node Destructuring with pcase Patterns @subsection Destructuring with @code{pcase} Patterns @cindex destructuring with pcase patterns Pcase patterns not only express a condition on the form of the objects they can match, but they can also extract sub-fields of those objects. For example we can extract 2 elements from a list that is the value of the variable @code{my-list} with the following code: @example (pcase my-list (`(add ,x ,y) (message "Contains %S and %S" x y))) @end example This will not only extract @code{x} and @code{y} but will additionally test that @code{my-list} is a list containing exactly 3 elements and whose first element is the symbol @code{add}. If any of those tests fail, @code{pcase} will immediately return @code{nil} without calling @code{message}. Extraction of multiple values stored in an object is known as @dfn{destructuring}. Using @code{pcase} patterns allows you to perform @dfn{destructuring binding}, which is similar to a local binding (@pxref{Local Variables}), but gives values to multiple elements of a variable by extracting those values from an object of compatible structure. The macros described in this section use @code{pcase} patterns to perform destructuring binding. The condition of the object to be of compatible structure means that the object must match the pattern, because only then the object's subfields can be extracted. For example: @example (pcase-let ((`(add ,x ,y) my-list)) (message "Contains %S and %S" x y)) @end example @noindent does the same as the previous example, except that it directly tries to extract @code{x} and @code{y} from @code{my-list} without first verifying if @code{my-list} is a list which has the right number of elements and has @code{add} as its first element. The precise behavior when the object does not actually match the pattern is undefined, although the body will not be silently skipped: either an error is signaled or the body is run with some of the variables potentially bound to arbitrary values like @code{nil}. The pcase patterns that are useful for destructuring bindings are generally those described in @ref{Backquote Patterns}, since they express a specification of the structure of objects that will match. For an alternative facility for destructuring binding, see @ref{seq-let}. @defmac pcase-let bindings body@dots{} Perform destructuring binding of variables according to @var{bindings}, and then evaluate @var{body}. @var{bindings} is a list of bindings of the form @w{@code{(@var{pattern} @var{exp})}}, where @var{exp} is an expression to evaluate and @var{pattern} is a @code{pcase} pattern. All @var{exp}s are evaluated first, after which they are matched against their respective @var{pattern}, introducing new variable bindings that can then be used inside @var{body}. The variable bindings are produced by destructuring binding of elements of @var{pattern} to the values of the corresponding elements of the evaluated @var{exp}. Here's a trivial example: @example (pcase-let ((`(,major ,minor) (split-string "image/png" "/"))) minor) @result{} "png" @end example @end defmac @defmac pcase-let* bindings body@dots{} Perform destructuring binding of variables according to @var{bindings}, and then evaluate @var{body}. @var{bindings} is a list of bindings of the form @code{(@var{pattern} @var{exp})}, where @var{exp} is an expression to evaluate and @var{pattern} is a @code{pcase} pattern. The variable bindings are produced by destructuring binding of elements of @var{pattern} to the values of the corresponding elements of the evaluated @var{exp}. Unlike @code{pcase-let}, but similarly to @code{let*}, each @var{exp} is matched against its corresponding @var{pattern} before processing the next element of @var{bindings}, so the variable bindings introduced in each one of the @var{bindings} are available in the @var{exp}s of the @var{bindings} that follow it, additionally to being available in @var{body}. @end defmac @defmac pcase-dolist (pattern list) body@dots{} Execute @var{body} once for each element of @var{list}, on each iteration performing a destructuring binding of variables in @var{pattern} to the values of the corresponding subfields of the element of @var{list}. The bindings are performed as if by @code{pcase-let}. When @var{pattern} is a simple variable, this ends up being equivalent to @code{dolist} (@pxref{Iteration}). @end defmac @defmac pcase-setq pattern value@dots{} Assign values to variables in a @code{setq} form, destructuring each @var{value} according to its respective @var{pattern}. @end defmac @defmac pcase-lambda lambda-list &rest body This is like @code{lambda}, but allows each argument to be a pattern. For instance, here's a simple function that takes a cons cell as the argument: @example (setq fun (pcase-lambda (`(,key . ,val)) (vector key (* val 10)))) (funcall fun '(foo . 2)) @result{} [foo 20] @end example @end defmac From debbugs-submit-bounces@debbugs.gnu.org Sat May 04 11:23:54 2024 Received: (at 70597) by debbugs.gnu.org; 4 May 2024 15:23:54 +0000 Received: from localhost ([127.0.0.1]:54247 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s3HEw-0001zq-7a for submit@debbugs.gnu.org; Sat, 04 May 2024 11:23:54 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:30569) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s3HEs-0001zg-4c for 70597@debbugs.gnu.org; Sat, 04 May 2024 11:23:52 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id A72F080919; Sat, 4 May 2024 11:23:20 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1714836199; bh=oBRpg2+3as6LH4OyfMvyC4GJ+wYDmZYG82IlLCDbR8Q=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=UKdBOR7aTEPBRZ6FVQyrOFQS/R+qBQ927Fv6BUnN+tCoBLZLfKVovsERfNqbyIZ2R 3l9UHCzS22dpZ5x6je6wnaUBI2jTSU/eNHspIjZ2sV25jnRHohURn6vk92RR66qNpP 59kqWcuhtU1zwFko7ukfjnaS+K2EFzx8taI//86+8L6HIfY3pJ8h+zHTJc6EywYNqL +cb/Hhxk9RkFSQiIgCL/YLdyVqAt36+hKXpA2hDoz/0mIzUWsmzy7ukmRLpt2pS98I ZRtKN79qXwF8Adw4dsQhLv5dY4aeT9FWckme7ii+zIgW4sNbLOETLWFiWZ3Al1BmI1 IURGp7jCrNIiA== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 1D61E805E0; Sat, 4 May 2024 11:23:19 -0400 (EDT) Received: from pastel (unknown [45.72.201.215]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B17B31206A7; Sat, 4 May 2024 11:23:18 -0400 (EDT) From: Stefan Monnier To: Marco Antoniotti Subject: Re: bug#70597: Problem in pcase-let? In-Reply-To: (Stefan Monnier's message of "Sun, 28 Apr 2024 17:08:21 -0400") Message-ID: References: <662d23bf.050a0220.a4e2f.3f45@mx.google.com> Date: Sat, 04 May 2024 11:23:16 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.044 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 70597 Cc: Bruno Barbier , 70597@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > I haven't looked at the code for it, so I don't know how easy it is to > implement, but let' hope there's an "easy" way to do it. Hmm... the patch below kind of works, but it's not ideal and it's not easy to fix its shortcomings: - It happens a bit "too late", i.e. at a level where the pattern has already been macro-expanded so the message may refer to a subpattern that's not readily present in the source code. [ I think we can live with this. ] - It applies to more situations than just `pcase-let`, and for some of them the warning is not desirable. - It has a few false positives. This last point is because of a fuzziness about what it is we want to warn about: in a pattern like `[a ,b] there are fundamentally 3 tests: - Is the pattern of type `vector`. - Does the vector have size 2. - Is the first element equal to `a`. We want to drop all three. But we don't want to warn about the first two, since there's no convenient way to write a pattern without them. But for some other patterns the equivalent to the first point above can look like `(equal (type-of foo) 'bar)` and thus ends up caught in our warning (which basically warns when we test that something is equal to some constant), even though there's no other way to write the pattern. Stefan diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el index 23f1bac600c..f0302dbcbe0 100644 --- a/lisp/emacs-lisp/pcase.el +++ b/lisp/emacs-lisp/pcase.el @@ -1050,6 +1058,11 @@ pcase--u1 `((,nsym ,(pcase--funcall fun sym vars))) body)))) ((eq (car-safe upat) 'quote) + (when (and (length= rest 1) + (not (memq (cadr upat) '(nil _))) ;Too common. + (eq 'match (car-safe (caar rest))) + (eq 'pcase--dontcare (cddr (caar rest)))) + (message "Ignoring pattern %S, you might replace it with _" upat)) (pcase--mark-used sym) (let* ((val (cadr upat)) (splitrest (pcase--split-rest From debbugs-submit-bounces@debbugs.gnu.org Sun May 05 04:50:20 2024 Received: (at 70597-done) by debbugs.gnu.org; 5 May 2024 08:50:20 +0000 Received: from localhost ([127.0.0.1]:58502 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s3XZb-0002gK-OR for submit@debbugs.gnu.org; Sun, 05 May 2024 04:50:20 -0400 Received: from mail-yb1-xb2f.google.com ([2607:f8b0:4864:20::b2f]:48403) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s3XZX-0002g7-IO for 70597-done@debbugs.gnu.org; Sun, 05 May 2024 04:50:19 -0400 Received: by mail-yb1-xb2f.google.com with SMTP id 3f1490d57ef6-d9b9adaf291so828618276.1 for <70597-done@debbugs.gnu.org>; Sun, 05 May 2024 01:49:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714898986; x=1715503786; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=wYcLseDCkElvt42BUptEsZKXekSrj/OT5QM+fgW1xbE=; b=A/IgZ1j/fOA95UF7LHwKb8ZyP0HoRzo9piU49dgAURdgo3uxTi1djDG/Mr8IwsShuk 9amc9bodSxqaTv4zh9jhoshY34acgVWDVJguGQeOBO8lOyEhQnCmZq0NGi5QUl9RB4Ib zUW2y/ynLPp/yrUKPn03XAZyGKoE+iQXmtJIgtuYelOGMr+0SEVyxGO9FiThAwxszzBa 0NQ1173qDtWK0JRroMgwJHkkpg7d61VG1yKvselNbiXWyCMjRibMyM92jiUS+h9txD1W Bgheam5TrxSYXgNMFmb/5gYYJBABNPvYvIDq+GkLXh6hNFiTn6pHWbSN/okBKucgaJhC HFOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714898986; x=1715503786; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wYcLseDCkElvt42BUptEsZKXekSrj/OT5QM+fgW1xbE=; b=cCM4s4GVuISP9p654Ox0vXr+6vJO/BGlKyk/yL0ajraYp14r3Z1hIxCczC3aPI3Oft 53oD0X4UQOb+/A8hDXV+5rAvJGnPpTDg21c7liJFCckf+qCh1UNBAwEyymZmE+ZzBSiV ns49ec0GADw/AcrHIj2X7wWT4DfhrzVThp2vgLW+z61ceGtjwxgOQHzXH4QlChnkUd7A sKhrxQdbOwY8alUFcfTYCnb+ynRDx3KUJBmkxoN5T8+7Zd06Zibllt+ybIU59q3BXSQ/ e1il29+eSgJKoWHUSLVY52RuiI4AQsAHlxkPRUmcqsYcKtMT/+76e9S/CewvZJbxw6w/ YHpA== X-Forwarded-Encrypted: i=1; AJvYcCU9YP9r+U9rLlg20Quas67wjezCSVZ0WIh9Qa29i5kVzflj2Y+700PD+PsZe0fyBkefA7LGGIlwqF7losivM5KewvsZ242QyywOMw== X-Gm-Message-State: AOJu0YzaIGJzMWfO61gcibT7MElhovfBPAzm0qVmhwco0cupiBERmBGF Qnfw33f+g8TVkkvjEcUyBI/mvNlEacdDFcIEykzQxxoaQ5YwbRy/Mya9o1obDFBl0wHlfulA4Y9 zd9W8kob0QcEMTYBbJAEAwX/9grk= X-Google-Smtp-Source: AGHT+IG41be1Ru1vbHowyJI2I+PNURMZX4eZOvr6dZ6a3HEuCwLSEfVqnrp5FaZPSINlISrbYLJDodFAHsjNNUzIRaU= X-Received: by 2002:a25:9383:0:b0:de5:5266:bbbc with SMTP id a3-20020a259383000000b00de55266bbbcmr6501603ybm.28.1714898985316; Sun, 05 May 2024 01:49:45 -0700 (PDT) MIME-Version: 1.0 References: <662d23bf.050a0220.a4e2f.3f45@mx.google.com> <865xvwmus2.fsf@gnu.org> <861q6hhks0.fsf@gnu.org> In-Reply-To: From: Marco Antoniotti Date: Sun, 5 May 2024 10:49:33 +0200 Message-ID: Subject: Re: bug#70597: Problem in pcase-let? To: Stefan Monnier Content-Type: multipart/alternative; boundary="000000000000d87b2c0617b10803" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 70597-done Cc: brubar.cs@gmail.com, Eli Zaretskii , 70597-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --000000000000d87b2c0617b10803 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Stefan, i usually just to C-h f. This is what you get from it, in 29.3. Like `let', but supports destructuring BINDINGS using `pcase' patterns. BODY should be a list of expressions, and BINDINGS should be a list of bindings of the form (PATTERN EXP). All EXPs are evaluated first, and then used to perform destructuring bindings by matching each EXP against its respective PATTERN. Then BODY is evaluated with those bindings in effect. Each EXP should match its respective PATTERN (i.e. be of structure compatible to PATTERN); a mismatch may signal an error or may go undetected, binding variables to arbitrary values, such as nil. Probably introduced at or before Emacs version 28.1. The Info doc you posted is definitively better. All the best MA On Sat, May 4, 2024 at 5:05=E2=80=AFPM Stefan Monnier wrote: > > sorry, but I do not think that the current doc string and/or the > > manual explains the situation. > > Which "current" are you referring to? The "current" manual (in > `master`) has a whole section on "Destructuring with pcase pattern" > (see below). > > Do you still see room for misunderstanding there? > If so, can you suggest how to change it to make it more clear? > > > Stefan > > > @node Destructuring with pcase Patterns > @subsection Destructuring with @code{pcase} Patterns > @cindex destructuring with pcase patterns > > Pcase patterns not only express a condition on the form of the objects > they can match, but they can also extract sub-fields of those objects. > For example we can extract 2 elements from a list that is the value of > the variable @code{my-list} with the following code: > > @example > (pcase my-list > (`(add ,x ,y) (message "Contains %S and %S" x y))) > @end example > > This will not only extract @code{x} and @code{y} but will additionally > test that @code{my-list} is a list containing exactly 3 elements and > whose first element is the symbol @code{add}. If any of those tests > fail, @code{pcase} will immediately return @code{nil} without calling > @code{message}. > > Extraction of multiple values stored in an object is known as > @dfn{destructuring}. Using @code{pcase} patterns allows you to > perform @dfn{destructuring binding}, which is similar to a local > binding (@pxref{Local Variables}), but gives values to multiple > elements of a variable by extracting those values from an object of > compatible structure. > > The macros described in this section use @code{pcase} patterns to > perform destructuring binding. The condition of the object to be of > compatible structure means that the object must match the pattern, > because only then the object's subfields can be extracted. For > example: > > @example > (pcase-let ((`(add ,x ,y) my-list)) > (message "Contains %S and %S" x y)) > @end example > > @noindent > does the same as the previous example, except that it directly tries > to extract @code{x} and @code{y} from @code{my-list} without first > verifying if @code{my-list} is a list which has the right number of > elements and has @code{add} as its first element. The precise > behavior when the object does not actually match the pattern is > undefined, although the body will not be silently skipped: either an > error is signaled or the body is run with some of the variables > potentially bound to arbitrary values like @code{nil}. > > The pcase patterns that are useful for destructuring bindings are > generally those described in @ref{Backquote Patterns}, since they > express a specification of the structure of objects that will match. > > For an alternative facility for destructuring binding, see > @ref{seq-let}. > > @defmac pcase-let bindings body@dots{} > Perform destructuring binding of variables according to > @var{bindings}, and then evaluate @var{body}. > > @var{bindings} is a list of bindings of the form @w{@code{(@var{pattern} > @var{exp})}}, where @var{exp} is an expression to evaluate and > @var{pattern} is a @code{pcase} pattern. > > All @var{exp}s are evaluated first, after which they are matched > against their respective @var{pattern}, introducing new variable > bindings that can then be used inside @var{body}. The variable > bindings are produced by destructuring binding of elements of > @var{pattern} to the values of the corresponding elements of the > evaluated @var{exp}. > > Here's a trivial example: > > @example > (pcase-let ((`(,major ,minor) > (split-string "image/png" "/"))) > minor) > @result{} "png" > @end example > @end defmac > > @defmac pcase-let* bindings body@dots{} > Perform destructuring binding of variables according to > @var{bindings}, and then evaluate @var{body}. > > @var{bindings} is a list of bindings of the form @code{(@var{pattern} > @var{exp})}, where @var{exp} is an expression to evaluate and > @var{pattern} is a @code{pcase} pattern. The variable bindings are > produced by destructuring binding of elements of @var{pattern} to the > values of the corresponding elements of the evaluated @var{exp}. > > Unlike @code{pcase-let}, but similarly to @code{let*}, each @var{exp} > is matched against its corresponding @var{pattern} before processing > the next element of @var{bindings}, so the variable bindings > introduced in each one of the @var{bindings} are available in the > @var{exp}s of the @var{bindings} that follow it, additionally to > being available in @var{body}. > @end defmac > > @defmac pcase-dolist (pattern list) body@dots{} > Execute @var{body} once for each element of @var{list}, on each > iteration performing a destructuring binding of variables in > @var{pattern} to the values of the corresponding subfields of the > element of @var{list}. The bindings are performed as if by > @code{pcase-let}. When @var{pattern} is a simple variable, this ends > up being equivalent to @code{dolist} (@pxref{Iteration}). > @end defmac > > @defmac pcase-setq pattern value@dots{} > Assign values to variables in a @code{setq} form, destructuring each > @var{value} according to its respective @var{pattern}. > @end defmac > > @defmac pcase-lambda lambda-list &rest body > This is like @code{lambda}, but allows each argument to be a pattern. > For instance, here's a simple function that takes a cons cell as the > argument: > > @example > (setq fun > (pcase-lambda (`(,key . ,val)) > (vector key (* val 10)))) > (funcall fun '(foo . 2)) > @result{} [foo 20] > @end example > @end defmac > > > --=20 Marco Antoniotti Somewhere over the Rainbow --000000000000d87b2c0617b10803 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Stefan,

i usually just to= C-h f.=C2=A0 This is what you get from it, in 29.3.

Like `let', but = supports destructuring BINDINGS using `pcase' patterns.
BODY should be a list of expressions, and = BINDINGS should be a list of
bindings of the form (PATTERN EXP).
All EXPs are evaluated first, and then used to perform destructu= ring
bindings by matching e= ach EXP against its respective PATTERN.=C2=A0 Then
BODY is evaluated with those bindings in effect.

Each EXP should match its respective PATTERN (i.e. be o= f structure
compatible to P= ATTERN); a mismatch may signal an error or may go
undetected, binding variables to arbitrary values, s= uch as nil.

=C2=A0 Probably introduced at or before E= macs version 28.1.

The Info doc you p= osted is definitively better.

All the best

MA



On Sat, May 4, 2024= at 5:05=E2=80=AFPM Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> sorry, but I do not think that the cu= rrent doc string and/or the
> manual explains the situation.

Which "current" are you referring to?=C2=A0 The "current&quo= t; manual (in
`master`) has a whole section on "Destructuring with pcase pattern&quo= t;
(see below).

Do you still see room for misunderstanding there?
If so, can you suggest how to change it to make it more clear?


=C2=A0 =C2=A0 =C2=A0 =C2=A0 Stefan


@node Destructuring with pcase Patterns
@subsection Destructuring with @code{pcase} Patterns
@cindex destructuring with pcase patterns

Pcase patterns not only express a condition on the form of the objects
they can match, but they can also extract sub-fields of those objects.
For example we can extract 2 elements from a list that is the value of
the variable @code{my-list} with the following code:

@example
=C2=A0 (pcase my-list
=C2=A0 =C2=A0 (`(add ,x ,y)=C2=A0 (message "Contains %S and %S" x= y)))
@end example

This will not only extract @code{x} and @code{y} but will additionally
test that @code{my-list} is a list containing exactly 3 elements and
whose first element is the symbol @code{add}.=C2=A0 If any of those tests fail, @code{pcase} will immediately return @code{nil} without calling
@code{message}.

Extraction of multiple values stored in an object is known as
@dfn{destructuring}.=C2=A0 Using @code{pcase} patterns allows you to
perform @dfn{destructuring binding}, which is similar to a local
binding (@pxref{Local Variables}), but gives values to multiple
elements of a variable by extracting those values from an object of
compatible structure.

The macros described in this section use @code{pcase} patterns to
perform destructuring binding.=C2=A0 The condition of the object to be of compatible structure means that the object must match the pattern,
because only then the object's subfields can be extracted.=C2=A0 For example:

@example
=C2=A0 (pcase-let ((`(add ,x ,y) my-list))
=C2=A0 =C2=A0 (message "Contains %S and %S" x y))
@end example

@noindent
does the same as the previous example, except that it directly tries
to extract @code{x} and @code{y} from @code{my-list} without first
verifying if @code{my-list} is a list which has the right number of
elements and has @code{add} as its first element.=C2=A0 The precise
behavior when the object does not actually match the pattern is
undefined, although the body will not be silently skipped: either an
error is signaled or the body is run with some of the variables
potentially bound to arbitrary values like @code{nil}.

The pcase patterns that are useful for destructuring bindings are
generally those described in @ref{Backquote Patterns}, since they
express a specification of the structure of objects that will match.

For an alternative facility for destructuring binding, see
@ref{seq-let}.

@defmac pcase-let bindings body@dots{}
Perform destructuring binding of variables according to
@var{bindings}, and then evaluate @var{body}.

@var{bindings} is a list of bindings of the form @w{@code{(@var{pattern} @var{exp})}}, where @var{exp} is an expression to evaluate and
@var{pattern} is a @code{pcase} pattern.

All @var{exp}s are evaluated first, after which they are matched
against their respective @var{pattern}, introducing new variable
bindings that can then be used inside @var{body}.=C2=A0 The variable
bindings are produced by destructuring binding of elements of
@var{pattern} to the values of the corresponding elements of the
evaluated @var{exp}.

Here's a trivial example:

@example
(pcase-let ((`(,major ,minor)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(split-string "image/p= ng" "/")))
=C2=A0 minor)
=C2=A0 =C2=A0 =C2=A0@result{} "png"
@end example
@end defmac

@defmac pcase-let* bindings body@dots{}
Perform destructuring binding of variables according to
@var{bindings}, and then evaluate @var{body}.

@var{bindings} is a list of bindings of the form @code{(@var{pattern}
@var{exp})}, where @var{exp} is an expression to evaluate and
@var{pattern} is a @code{pcase} pattern.=C2=A0 The variable bindings are produced by destructuring binding of elements of @var{pattern} to the
values of the corresponding elements of the evaluated @var{exp}.

Unlike @code{pcase-let}, but similarly to @code{let*}, each @var{exp}
is matched against its corresponding @var{pattern} before processing
the next element of @var{bindings}, so the variable bindings
introduced in each one of the @var{bindings} are available in the
@var{exp}s of the @var{bindings} that follow it, additionally to
being available in @var{body}.
@end defmac

@defmac pcase-dolist (pattern list) body@dots{}
Execute @var{body} once for each element of @var{list}, on each
iteration performing a destructuring binding of variables in
@var{pattern} to the values of the corresponding subfields of the
element of @var{list}.=C2=A0 The bindings are performed as if by
@code{pcase-let}.=C2=A0 When @var{pattern} is a simple variable, this ends<= br> up being equivalent to @code{dolist} (@pxref{Iteration}).
@end defmac

@defmac pcase-setq pattern value@dots{}
Assign values to variables in a @code{setq} form, destructuring each
@var{value} according to its respective @var{pattern}.
@end defmac

@defmac pcase-lambda lambda-list &rest body
This is like @code{lambda}, but allows each argument to be a pattern.
For instance, here's a simple function that takes a cons cell as the argument:

@example
(setq fun
=C2=A0 =C2=A0 =C2=A0 (pcase-lambda (`(,key . ,val))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (vector key (* val 10))))
(funcall fun '(foo . 2))
=C2=A0 =C2=A0 @result{} [foo 20]
@end example
@end defmac




--
Marco Antonio= tti
Somewhere over the Rainbow
--000000000000d87b2c0617b10803-- From unknown Sun Jun 22 08:07:47 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 02 Jun 2024 11:24:11 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator