From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lynn Winebarger Newsgroups: gmane.emacs.devel Subject: Re: Instead of pcase Date: Sun, 10 Dec 2023 11:27:35 -0500 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> <87zfza2aq2.fsf@web.de> <7nmsv9zq6u.fsf@ecube.ecubist.org> <7nv89x5tsi.fsf@ecube.ecubist.org> <87o7focuf5.fsf@web.de> <875y1r10jr.fsf@web.de> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000491f20060c2a4c23" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27675"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Michael Heerdegen , emacs-devel To: Richard Stallman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Dec 10 17:28:49 2023 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 1rCMfg-00070X-Qp for ged-emacs-devel@m.gmane-mx.org; Sun, 10 Dec 2023 17:28:48 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rCMeo-0004TB-9F; Sun, 10 Dec 2023 11:27:54 -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 1rCMen-0004T3-A6 for emacs-devel@gnu.org; Sun, 10 Dec 2023 11:27:53 -0500 Original-Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rCMel-0008UA-HS; Sun, 10 Dec 2023 11:27:53 -0500 Original-Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-28659348677so2717282a91.0; Sun, 10 Dec 2023 08:27:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702225668; x=1702830468; darn=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=uK8++hw44YYZlxfrImraj18T0Vs6tphCepdfgEBwv9c=; b=kQF4NWY9IcrcWxlClmNh5OFy9q8fk6PDvfVOmP7oWC3DWNCIVjf2E0ye8XCHNcF8dF 3DxXnHnZhWMMAsO8qsrVxkc+fJu24MhOp0hCBLK8t54KYRWrCkilY7FTLYyeZ83iC68D W++/TfJ43BtMvcG8omhKJkNIyGeC86PPlGpEZ+LXuTpCPMAgqDsEIJRZ6+8Ax4S95LJC PIjvz6UmFOcHF6snyShYPU3cX4Ynd6X9S8I+1yAML45Zj0FEoMCTRWB2WM9xZyhLiWOo owWotCRYzQgjKiwl5ZjMQK+wkcGyHnk/OM1yN9/FmkktlRDmFiJ6mEBpDa1X8Jg69ydT YdDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702225668; x=1702830468; 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=uK8++hw44YYZlxfrImraj18T0Vs6tphCepdfgEBwv9c=; b=RYHOX8a/xIfLB11pLIGqBtk+u3st5R8H8D3Rj3TwtCXRtfQvzk2wldbpAQ4tZUfuRY /ZLxtQ9nryx5Jsk+tu7n33F2GF/D28F8Yq79oXRPE3EpvWVusQMBsaSBVsHlxDrXiVCR U59wq5ki7J1rQ9dxsAeo9S0j3IIeNmYUWzg+RJT4wuZjYIaaqAtTlp+a/ceT/uQ42Jzm /bpfCFGmLeiUDKlH/jSgtHrP0Jg87q9zQC/DSGAtgjmivK5Xelj2l5hdafk68p2/uetf bQ5SJRnFqRM71A/lTGnOvOVbGQtTUisY0z5LtjgBbsWZv1wW8CT+mMc6Xfst1QoFj5RZ uDwA== X-Gm-Message-State: AOJu0YymEeUCOOFZupLV2glPYlez52scdOE7x4ud/VySuDaz21Smar8O WJXhYHxtyVo5Pwo2OSDtqp4LPK4KJkztBYrRocSjHXzQ/Sw= X-Google-Smtp-Source: AGHT+IG34FhVnrPgipjnsdi1mfuTG4q8oSIq1fxQtO84I1yoe9K/JzrtbblwHk0DXdauPnAWB+9Kc6SUcck2UuSxxRw= X-Received: by 2002:a17:90b:33cb:b0:286:7529:3598 with SMTP id lk11-20020a17090b33cb00b0028675293598mr4416509pjb.13.1702225668282; Sun, 10 Dec 2023 08:27:48 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=owinebar@gmail.com; helo=mail-pj1-x1036.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, 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:313679 Archived-At: --000000000000491f20060c2a4c23 Content-Type: text/plain; charset="UTF-8" On Sun, Dec 10, 2023, 10:14 AM Richard Stallman wrote: > [[[ To any NSA and FBI agents reading my email: please consider ]]] > [[[ whether defending the US Constitution against all enemies, ]]] > [[[ foreign or domestic, requires you to follow Snowden's example. ]]] > > I am trying to rewrite `byte-optimize-letX' with cond*, > but I cannot understand its current definition. > > Specifically, I can't understand this pcase clause: > > ;; Body is last variable. > (`(,head ,(and bindings > (let last-var (caar (last bindings)))) > ,(and last-var ; non-linear pattern > (pred symbolp) (pred (not keywordp)) (pred (not > booleanp)))) > (if (eq head 'let) > `(progn ,@(mapcar #'cadr bindings)) > `(,head ,(butlast bindings) ,(cadar (last bindings))))) > > What case is it meant to handle? What does that case look like? > The pattern would match a let or let* form that has bindings but no body. If it's a let form, the bindings are unused since only code in the body would see the bound variables. So the optimization is to transform the value expressions of the bindings into a progn. If it's a let* form, then the last bound variables would only be visible in the body, but there is none. Therefore, the last variable binding is eliminated and its value expression is made into the body. Lynn --000000000000491f20060c2a4c23 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sun, Dec 10, 2023, 10:14 AM Richard Stallman <rms@gnu.org> wrote:
[[[ To any NSA and FBI agents reading my email: please consid= er=C2=A0 =C2=A0 ]]]
[[[ whether defending the US Constitution against all enemies,=C2=A0 =C2=A0= =C2=A0]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]<= br>
I am trying to rewrite `byte-optimize-letX' with cond*,
but I cannot understand its current definition.

Specifically, I can't understand this pcase clause:

=C2=A0 =C2=A0 ;; Body is last variable.
=C2=A0 =C2=A0 (`(,head ,(and bindings
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(let l= ast-var (caar (last bindings))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0,(and last-var=C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0; non-linear pattern
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(pred = symbolp) (pred (not keywordp)) (pred (not booleanp))))
=C2=A0 =C2=A0 =C2=A0(if (eq head 'let)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0`(progn ,@(mapcar #'cadr bindings)) =C2=A0 =C2=A0 =C2=A0 =C2=A0`(,head ,(butlast bindings) ,(cadar (last bindin= gs)))))

What case is it meant to handle?=C2=A0 What does that case look like?

The pa= ttern would match a let or let* form that has bindings but no body.=C2=A0= =C2=A0

If it's a let= form, the bindings are unused since only code in the body would see the bo= und variables.=C2=A0 So the optimization is to transform the value expressi= ons of the bindings into a progn.

If it's a let* form, then the last bound variables would only= be visible in the body, but there is none.=C2=A0 Therefore, the last varia= ble binding is eliminated and its value expression is made into the body.

Lynn

--000000000000491f20060c2a4c23--