From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: JD Smith Newsgroups: gmane.emacs.devel Subject: Re: Code for cond* Date: Thu, 25 Jan 2024 10:37:38 -0500 Message-ID: <4B3E3A7E-677C-43A2-92B3-562E99A8B897@gmail.com> References: <1AD5807F-91F7-4B92-BCB0-D0FEA904A75D@gmail.com> <67B51664-352E-4EB1-AE17-6D571999FDDE@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.300.61.1.2\)) 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="12756"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Madhu , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Jan 25 16:38:27 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 1rT1oA-00038x-SV for ged-emacs-devel@m.gmane-mx.org; Thu, 25 Jan 2024 16:38:26 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT1nd-00026D-Ra; Thu, 25 Jan 2024 10:37:53 -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 1rT1nc-00025J-2U for emacs-devel@gnu.org; Thu, 25 Jan 2024 10:37:52 -0500 Original-Received: from mail-qv1-xf32.google.com ([2607:f8b0:4864:20::f32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rT1na-0005Yo-J2 for emacs-devel@gnu.org; Thu, 25 Jan 2024 10:37:51 -0500 Original-Received: by mail-qv1-xf32.google.com with SMTP id 6a1803df08f44-686a92a8661so13215046d6.0 for ; Thu, 25 Jan 2024 07:37:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706197069; x=1706801869; darn=gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=8sdYRglSeblVjXvj7tZhwR/xt2SbL3lROtUNGEbrapM=; b=BFG5kNSi/nsvg/f6uDej7m4KzF1cEpHmZVd3zEvR5KgocE7sb+4xkAARfuBE4ewIQH 1frXZdURhFIpcobm//3trWa+iG2AcbTL3aQjdUUhFCSw5Wh3GEjeZJdGGOfRmf28+mOX N73ljJrFx3MyA0bZYqChKQQJW1PbVkfsuORHVGkqtyrEQJvsXQ70yFEZLh8oOR7/IzeT 2NTdx8yZd5HCj+sfBnsfnr1WbpI6/X7AWBwGl/EpekTXs52K/orcBgyiBFEivfMDdeZ8 h8MS35vEUxOl+mmai5EsB5MkjNeroJnmY0OvnmN8xI9Jwwy1/768gMLvpqauI7RQSbuw dkow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706197069; x=1706801869; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8sdYRglSeblVjXvj7tZhwR/xt2SbL3lROtUNGEbrapM=; b=cF0Bk+9D2xiPHveUtYZwXyJjIqjoE36xJf9vaWvzoZt4x2lzzJ7Y8GBp2B+8LKGhIn dJlQ5kC9tREP2IJjupD7sVrPV6Jeik/+Cd/Vus4oQ2jIrwTCbw6IENrHwsjcHkzMlJIf VXG50WGG7G1AN1oBypJsDCp4ZmxsyOUsE6QN700YO3YFwhCSCurtirUq3WStcqH2Y/2v kQPjOmqnFMni8C7bkLOhJe8MdttDqWT+9cQ/at2iCy/LGnsseoUiZfM7bl5wICrcCsBs vdif52zM1gAHXoJ3/MEbx97UFBisMuZ2MwspT63PL71f+Meo/4eNVcVg6ziQE4gic21e U7gQ== X-Gm-Message-State: AOJu0Yw7AagBzlcGdAjlsNeDfljcf2CiEIKV132EbXCfeLxVJZv4DReA CjlyIxfw4V0wzztNtL+Dg+KeNHKd64eS4tu22Rf8A02N6q64NELh X-Google-Smtp-Source: AGHT+IGGZESqF7sCko2D3M1S5b1R4xofp1zFewigClLzJzSml/XPnkuSBWuKf+gOKbCoiU4mVdqyUA== X-Received: by 2002:ad4:5ae9:0:b0:680:f958:81d4 with SMTP id c9-20020ad45ae9000000b00680f95881d4mr1402716qvh.20.1706197069473; Thu, 25 Jan 2024 07:37:49 -0800 (PST) Original-Received: from smtpclient.apple (cm-24-53-187-34.buckeyecom.net. [24.53.187.34]) by smtp.gmail.com with ESMTPSA id bt12-20020ad455cc000000b0068179afede6sm5514184qvb.100.2024.01.25.07.37.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jan 2024 07:37:48 -0800 (PST) In-Reply-To: <67B51664-352E-4EB1-AE17-6D571999FDDE@gmail.com> X-Mailer: Apple Mail (2.3774.300.61.1.2) Received-SPF: pass client-ip=2607:f8b0:4864:20::f32; envelope-from=jdtsmith@gmail.com; helo=mail-qv1-xf32.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:315366 Archived-At: > On Jan 25, 2024, at 10:17=E2=80=AFAM, JD Smith = wrote: >=20 >=20 >=20 >> On Jan 25, 2024, at 8:57=E2=80=AFAM, Stefan Monnier = wrote: >>=20 >>>>=20 >>>> (cond-let >>>> (((var value) >>>> (dvar (derived-from var)) >>>> ((has-the-right-stuff-p dvar))) >>>> (cons 'correct dvar)) >>>>=20 >>>> (((foo value2) >>>> (bar (1- foo)) >>>> ((< bar 0))) >>>> (cons 'incorrect bar)) >>>>=20 >>>> (t nil)) >>=20 >=20 >> Personally, I was thinking of a syntax like >>=20 >> (my-cond >> (:let var value) >> (:let dvar (derived-from var)) >> ((has-the-right-stuff-p dvar) >> (cons 'correct dvar)) >>=20 >> (:let foo value2) >> (:let bar (1- foo)) >> ((< bar 0) >> (cons 'incorrect bar)) >>=20 >> (t nil)) And it perhaps goes without saying that the two approaches could be = combined :) =E2=80=94 (cond-let (:let var-for-rest value) (simple0-using-var-for-rest body0) ; a normal cond-like clause (bindings1 body1-including-var-for-rest) =20 (:let another-var (some-function var-for-rest)) (bindings2-using-another-var body2) (bindings3 body3-using-another-var) (t fallthrough-body))