From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.devel Subject: Re: Instead of pcase Date: Mon, 8 Jan 2024 21:33:43 -0800 Message-ID: References: <87fs169mjj.fsf@posteo.net> <093f11a1-57c2-5e56-d39b-26fef1c67cbb@gutov.dev> <25942.25061.217864.329049@retriever.mtv.corp.google.com> <87zfzdcz6z.fsf@posteo.net> <763f067b-4ca9-1eba-9f3c-424c38589e9c@gutov.dev> <83fs0navpj.fsf@gnu.org> <838r6ebfhw.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14658"; mail-complaints-to="usenet@ciao.gmane.io" Cc: owinebar@gmail.com, rms@gnu.org, dmitry@gutov.dev, philipk@posteo.net, emacs-devel@gnu.org To: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= , Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Jan 09 06:34:36 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rN4l2-0003g3-5o for ged-emacs-devel@m.gmane-mx.org; Tue, 09 Jan 2024 06:34:36 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rN4kI-0003lz-2f; Tue, 09 Jan 2024 00:33:50 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rN4kF-0003lH-Rk for emacs-devel@gnu.org; Tue, 09 Jan 2024 00:33:47 -0500 Original-Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rN4kE-0008HJ-78; Tue, 09 Jan 2024 00:33:47 -0500 Original-Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-5572a9b3420so6045351a12.1; Mon, 08 Jan 2024 21:33:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704778424; x=1705383224; darn=gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:from:to:cc:subject:date :message-id:reply-to; bh=NMJQPfvTzAs2WdjJpGwd0gTe78dYMM9XevoMbGEfm9Y=; b=MRcFyLHyNhK4WY4MY3pachUSkPFRu5M9QgbuPqZRKimNUxZymP7OpX5In9XEtDWiqR 1Wk/gqAxODKGtuUvK0537daHQHeY9oQcjuzm3HP74U7UnBTgn+YdX+CNZEnIrQnbNIuF Z6Ei8xXMs7hkW3bbM6KCawalm56+HNh1GXPAx6shQ7sSZ4P/0NCsL54xxK91qE/HhilT 9vEWZ+MMT9ZzmpRxYFJE1vTLx29bVNVLYs0s80G2CMfXox5pNWEJdkW5EAghNbktqYkr s53tXqdmAlrvFt/e4NQb15CqAm6xuAOZcuScgEy+ttfqDBCYIOP9AERmTM1amQqM5tx5 mRKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704778424; x=1705383224; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=NMJQPfvTzAs2WdjJpGwd0gTe78dYMM9XevoMbGEfm9Y=; b=LpD9OnKLzdBT0b6O2aR2a8jWLfJU0iKFAtu73kAwBWQqdzEdaUScUFF55jxwemPuTc f3sZI7XDKYZlrWfbcUgQRrxwKSb6S3VUH+chSNWebCkK4C3uGGBCMDIlQtbtqxUQTIvj 3TsjfcK5HyHWK/PMiZsOOl+s+VYH+526188WYceNQRf668XYu7AMzwbncJaSaokHH/tF TUS15Ie38FpX8JzqdInWBDW5cpvxC1tuOlrXLbDeNjMVQDeWCFLwqW6huZs6y4P7AAJ2 X8jMNxSM6hdUHjutMoVO/5eSUlIlXrFQIC1MJJ0riyAn2LBx7++wsUO3pyyYPvfxrDrO uf9Q== X-Gm-Message-State: AOJu0YwAP+kCrLI3S2G9E6qv0ocs874che5zQFg1HnMgjc7+1Y0edMn9 8yEIKRej1yqnuKD1GJrk7/PIpneJlSjXzbq6ygQ= X-Google-Smtp-Source: AGHT+IFigC7m4eI8LxF6IghccUajroI6Qmf0m/K/CC2mRhi+qsHx566Zv8lzsFLwBZW6KM43cieX2UjQD2LWSnpVYkM= X-Received: by 2002:a50:f695:0:b0:555:9bd7:a4f0 with SMTP id d21-20020a50f695000000b005559bd7a4f0mr216870edn.36.1704778423804; Mon, 08 Jan 2024 21:33:43 -0800 (PST) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 8 Jan 2024 21:33:43 -0800 In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::533; envelope-from=stefankangas@gmail.com; helo=mail-ed1-x533.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:314772 Archived-At: Jo=C3=A3o T=C3=A1vora writes: > It is _easy_ to explain that "scary" construct _if_ you learn to _lean_ > on what should be probably existing knowledge. No doc-consulting > necessary. > > You take a backtick-starting construct with as many scary periods > things as you can find and then, say > > `(,foo . (,bar . ,baz)) > > And then ask yourself: "what kind of list does this build if I just > let-bind foo, bar and baz to 42?". And then you answer yourself > "Why, it's the improper list (42 42 . 42) made up of just two cons > cells and 3 fixnums!". So _that's_ the kind of list that can be > destructured with the pcase expression. > > This solves the reading problem. Now the writing problem. To author > new pcase patterns one uses more or less the same process. One again > leans on one's existing knowledge of how the list structure would be > expressed with backtick-and-quote. So once you know the list > structure in your mind you write it as a backtick-and-quote expression, > just as if you were going to craft that list (though you aren't of > course). Then once you're happy with your expression, you may take it > and you put it in one of the BINDINGS left-hand part of a 'let'. > Then you rename that 'let' to 'pcase-let' and away you go! Could you reformat this as a documentation patch?