From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrew Hyatt Newsgroups: gmane.emacs.devel Subject: Re: pcase defuns Date: Wed, 22 Dec 2021 20:52:02 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; format=flowed Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11099"; mail-complaints-to="usenet@ciao.gmane.io" Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Dec 23 03:01:45 2021 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 1n0DQO-0002hS-M0 for ged-emacs-devel@m.gmane-mx.org; Thu, 23 Dec 2021 03:01:44 +0100 Original-Received: from localhost ([::1]:38090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0DQN-0004TS-0s for ged-emacs-devel@m.gmane-mx.org; Wed, 22 Dec 2021 21:01:43 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:37418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0DOG-0003V0-MB for emacs-devel@gnu.org; Wed, 22 Dec 2021 20:59:32 -0500 Original-Received: from [2607:f8b0:4864:20::736] (port=43708 helo=mail-qk1-x736.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n0DOE-0008O3-Ua; Wed, 22 Dec 2021 20:59:32 -0500 Original-Received: by mail-qk1-x736.google.com with SMTP id f138so4065448qke.10; Wed, 22 Dec 2021 17:59:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=GGZTAP4TQkr2eig+nhKikMUxT/1K1MYQTQwexZZIMl8=; b=UZMqpRzlHyFLW2byOFpBRdz3B0N8mk1hoBlCSI8EdZ1ZrzWQ3zD6RBDgkK941F9Y5w RGjoBCK2RLBreicoCJ52zLfvc/JTvq5VvsIIhPbAfLRPGbtNoFETIoUk6NmBkaCXadjf r5YWJ5WLS5nrzjtCoK+cxc7qpEeaT7A8R5Iw8Enc8pgOqloTXAe3w+DZEcCQ5mJCqrCu fdt4mW+NdzUMYxADcbxqXJD680kMSQ/FxsSe/IYzs04Er5hK9PWXJyb62ta2cCE/2qIA f7LXIP2bRyu2BkVQxPh+lRhEKaUHDngY7S6Wfzcq1Eac/1mjsdrIhFXjRqt5RxPOm89D mygQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=GGZTAP4TQkr2eig+nhKikMUxT/1K1MYQTQwexZZIMl8=; b=6DuBG2qRrrVtGe8lH7cwlkXVKIPzQ1antUBSWs5fLm/5BUzULiL0cgDyzc7fMrObkp +2UVBBV7lI5kvxdcX8RTUocAEwr9GyiRYlPszpUDd52hev5/HLkLVp8V8NWKZaZXzh4v /WXcd1NdDqoe4Oev+Evsf2DVZY2mAy/OloUIgQKqv731HxyhwurQj4nFGi8fcQjznbex sDAwXKuZVx9ZlMr/Ei9vgVNVf+DMY3kT6BA6f2R7sxMC7FwxUFxi2X3B8cVVCI62mkTA 6mz+z0hon1yshZgKxwqOfTQsvZtgLH0cOJuMFwG7We5x0Gu66FC04uFbARYvKeYEYQ9U npOg== X-Gm-Message-State: AOAM531qlYbwG+jfqIsCfh5NdESll4o/eeYGi6IxyCxJTMLb4Ex9GMZC htzx7uQfX64vROiykW27Nx0HU2/eA2M= X-Google-Smtp-Source: ABdhPJw/n6ayy2HOsLqsojuYbMCggzbCFDcMvkXbhCeCz0u1B+mRwnOXvqTDOVg5TE8mTvYCUbSCkw== X-Received: by 2002:a05:622a:1195:: with SMTP id m21mr314147qtk.514.1640224323992; Wed, 22 Dec 2021 17:52:03 -0800 (PST) Original-Received: from andrews-mbp.lan (pool-108-14-78-80.nycmny.fios.verizon.net. [108.14.78.80]) by smtp.gmail.com with ESMTPSA id z5sm2736931qti.57.2021.12.22.17.52.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Dec 2021 17:52:03 -0800 (PST) In-Reply-To: X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::736 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::736; envelope-from=ahyatt@gmail.com; helo=mail-qk1-x736.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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" Xref: news.gmane.io gmane.emacs.devel:282858 Archived-At: On Tue, Dec 21, 2021 at 11:18 PM 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 agree that just implementing everything in a function is > > reasonable. For that, just using pcase seems good enough, > > although it might be interesting to have a very different > > way of writing a function such as > > > (pcase-defun mytest > > "Demonstrates a way of writing defuns via pcase matching." > > ((a b _) "a b match") (`(c ,v _) (format "c %s match" v))) > > This avoids the split-up-definition problems I was talking > about, since it is all in one place with one name. > > Please make the defining form's name follow th convention of > starting with `def', so people and tools will recognize that it > is a defining form. > > Also, why use `pcase' in the name? According to the docs of > `pcase', this pattern matching is not similar. This really is the same as pcase, with some transformation to make the backquote-style and other style equivalent. For example, the above would translate to: (pcase val ((seq 'a 'b _) "a b match") (`(c ,v ,_) (format "c %s match" v))) I think we could probably just use pcase style, but I wanted to make the style more consistent between backquote and normal pcase matching. For example, backquote matching can match a sequence of matches, but normal matching would require the "seq" matcher at the start to do the same thing. It could be that the way I transform these can be improved, in fact, maybe the following would be better: (def-pcase mytest "Demonstrates a way of writing defuns via pcase matching." (('a 'b '_) "a b match") (('c v '_) (format "c %s match" v))) Or, as you say, perhaps if we use the name pcase we should just be completely consistent with how pcase does things, and not to make it more internally self-consistent. > > > -- > Dr Richard Stallman (https://stallman.org) > Chief GNUisance of the GNU Project (https://gnu.org) > Founder, Free Software Foundation (https://fsf.org) > Internet Hall-of-Famer (https://internethalloffame.org)