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: Tue, 21 Dec 2021 00:20:41 -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="36414"; 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 Tue Dec 21 06:22:01 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 1mzXb6-0009Bb-Jk for ged-emacs-devel@m.gmane-mx.org; Tue, 21 Dec 2021 06:22:00 +0100 Original-Received: from localhost ([::1]:39012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzXb5-0004f7-Hv for ged-emacs-devel@m.gmane-mx.org; Tue, 21 Dec 2021 00:21:59 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:46000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzXZy-0003Hl-T2 for emacs-devel@gnu.org; Tue, 21 Dec 2021 00:20:50 -0500 Original-Received: from [2607:f8b0:4864:20::f31] (port=42626 helo=mail-qv1-xf31.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mzXZt-0008Cy-9e; Tue, 21 Dec 2021 00:20:50 -0500 Original-Received: by mail-qv1-xf31.google.com with SMTP id q4so4823638qvh.9; Mon, 20 Dec 2021 21:20:44 -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=6ZdYDsfyAhZDSunj9Pk5AWvUNYsh6FDUc5FqZWBBzVY=; b=D0t9BKLB94jKpk9+HQ2okX+fhSjWGrn25pnC3omxYfRjDpuMswGp/LoT1lSTYsPOq2 foHa0ElilLuX1mzG//3/nPLL0fPYyd5OXUkBSVV5TfVTWSEuJZ+/O3A+S3ReWbR8fYVJ P00spkXfy9nWvG9f52QzLejdMsDCjPD4nKLt6D0Puql7KZEKWPl41vhUenKi/4qnC5GE Hl5p7t8wm3dn3Iwzslb8WjFvTp3luUwRvZo4I1e032bQzs1g4AUdu3+Otyve4JizPkuJ lJE9YUpuy1iQcY4SR1S01it86pH7lZmBtkiZ/kXMFaj1GBce2BFAR0ixHxUAbczBm+ml Pk6w== 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=6ZdYDsfyAhZDSunj9Pk5AWvUNYsh6FDUc5FqZWBBzVY=; b=6v2bXELCH6ZyTb7tEeZT/tD1rCYfsrY6Q2o+EdWI4v2WNq5FbZ/ESunsiHqKcBRmp1 japqgww1FRs62csqiPtlSb4tEcHj06n99XNJLhWV0ylCypdkhY9ODWGqW1KMTlUIHDIM o7+PuL3hoWHHHcDlOo2N0rHpBlMVocEXuQTGAKtTi4IonzvrIzL/Sxuo1Exn7VhpXEhp AIxg/yERm194n0wuWKFHG10iyB5U+oq3TXq+7v+u4HAktP6+1nGv9gkhY/Quu8bsEfwD NfkLloWBriXoGRJR8CIx/nNKwGF7WSNigQFEiJw2vRYc4xU6sqEMOfymVcDK3oLq1nnE xAaQ== X-Gm-Message-State: AOAM533PDXGxG5iXN+WYL9GSYdtPzAPya0DxiEAmZHIJ2Xq2T9S+NJqr YZtvdQVAPqJJUAhRSkYnRYuGGBjejMI= X-Google-Smtp-Source: ABdhPJyo678BN9AC2qgCO8JSir5r0gi5gMN4IQz85FxVKelMEG8TbbpYJwleUDwXOXP1QTBriwEl5Q== X-Received: by 2002:ad4:5c86:: with SMTP id o6mr1154414qvh.3.1640064043255; Mon, 20 Dec 2021 21:20:43 -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 bq43sm13188465qkb.32.2021.12.20.21.20.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Dec 2021 21:20:42 -0800 (PST) In-Reply-To: X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f31 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f31; envelope-from=ahyatt@gmail.com; helo=mail-qv1-xf31.google.com X-Spam_score_int: -8 X-Spam_score: -0.9 X-Spam_bar: / X-Spam_report: (-0.9 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=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:282562 Archived-At: On Mon, Dec 20, 2021 at 11:15 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. ]]] > > The idea of defining a function in pieces, scattered around one > or more files, is attractive as regards writing them. But it > creates an inconvenience for subsequent maintenance by other > people. > > The first thing you're likely to do when you see a call to a > function you don't know about is to find its definition. For a > piecewise-defined function, "the" definition doesn't exist. It > has a number of partial definitions, scattered around one file > or perhaps multiple files. > > If you think it is helpful for clarity to put the code for > handling various cases in various places in the file, no new > construct is needed for that. You can define a function for > handling each case, and put its definition in the place you want > it. Then define one overall function (you can think of it as > "generic") which detects the cases and calls those. > > This works with our tools. > > Let's contrast this with generic functions. > > A generic function has a single central definition which > describes how to call it. It is easy to find that. > > Finding the definitions of all the methods may be difficult. > You may need to grep for them. > > Calling the generic function selects a method by data types, and > you can generally tell, for given arguments, what data types > they have. You can probably tell that one method is the right > one without seeing all the others and comparing them. > > Thus, generic functions cause one kind of inconvenience for > studying a program, but avoids the other kinds. > > Let's not add any constructs that increase the level of > complexity of genericness beyond this. These are all good points, thanks. 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))) Not sure if I like this syntax, it does seem to lend itself to the idea of a pcase-centric way of programming, but it's also a bit odd, and doesn't seem to buy much. However, it does at least answer the objections raised to my initial proposal. Of course, so does not doing anything. > > > -- > 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)