From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.devel Subject: Re: Instead of pcase Date: Thu, 16 Nov 2023 23:55:01 +0100 Message-ID: <87a5rdcnqy.fsf@dataswamp.org> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="643"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: emacs-devel@gnu.org Cancel-Lock: sha1:n9G42K8R0LcydHx3rSRX0vwyPn0= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Nov 17 07:35:29 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 1r3sRt-000AVf-I9 for ged-emacs-devel@m.gmane-mx.org; Fri, 17 Nov 2023 07:35:29 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r3sRG-0001AA-EN; Fri, 17 Nov 2023 01:34: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 1r3lGd-0004IQ-DD for emacs-devel@gnu.org; Thu, 16 Nov 2023 17:55:23 -0500 Original-Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r3lGU-0005yK-5K for emacs-devel@gnu.org; Thu, 16 Nov 2023 17:55:22 -0500 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1r3lGR-0004nB-CG for emacs-devel@gnu.org; Thu, 16 Nov 2023 23:55:11 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-devel@gnu.org Mail-Copies-To: never Received-SPF: pass client-ip=116.202.254.214; envelope-from=ged-emacs-devel@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 17 Nov 2023 01:34:49 -0500 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:312847 Archived-At: Jim Porter wrote: >> Those of you who are fans of `pcase' may not recognize the >> cost it imposes on the Emacs Lisp language. You paid that >> cost already, perhaps a few years ago, and perhaps you >> enjoy each new language construct you learn. Perhaps, for >> you, the more complexity of features to be learned, >> the better. > > I'd like to offer a slightly different perspective here, as > someone who only fairly recently became comfortable with > Lisp (of any variety). I've used Emacs for a long time, but > I found Lisp completely incomprehensible until just a couple > of years ago. While getting started with Lisp isn't terribly > complex, it's still quite a bit to learn, and it took > a period where I was between jobs before I could dedicate > the time I needed to get comfortable with writing Lisp. > > I encountered a lot of hurdles with Lisp along the way. > The first one was extremely basic: I needed to get used to > the style of indentation and develop an intuition for > *reading* Lisp code, rather than slowly and laboriously > translating it into a form I could understand more easily. > > The next hurdle was quoting. I still remember that one of my > first patches to Emacs needed someone else to fix it in > a followup because I messed up the quoting. The issues of > quoting came up repeatedly for me as I encountered > progressively more complex examples of quoting. > > This is where we get to 'pcase'. I'll agree that the upper > limit on complex quoted forms in 'pcase' is very high. > I've used 'pcase-defmacro' in one nontrivial case, and > I found it very difficult to get right. > > *However*, 99% of the 'pcase' instances I've written or > encountered are pretty simple for me to understand. > Once I learned about 'pred' matcher and how to destructure > via backquote patterns, it was mostly smooth sailing for me. > > Now, while I'd certainly say that I enjoy learning overall > (or else I likely wouldn't have learned Lisp in the first > place), I don't consider the complexity of a feature to be > a positive. Instead, I prefer features that give me more > power or better expressiveness. Often, that expressiveness > comes at the cost of complexity under the hood (e.g. > 'pcase-defmacro'), but that's not a positive to me in and > of itself. > > Overall, 'pcase' is one of the parts of Elisp that > I appreciate the most. Learning the basics of its > mini-language took just a bit of reading. In addition to the > docs, seeing examples helped: the first few times were a bit > tricky to read, but I could usually understand what was > happening, even if I couldn't (at the time) write my own > 'pcase' code that worked. However, once I got the basics > down, I quickly saw the benefits: I could combine a handful > of basic tools to do bigger things, meaning I only need to > know a small set of facts before I can tackle a complex > task. This, to me, is the mark of a good language feature: > I can compose it in ways that *multiply* the power of each > (small, easy) bit. > > At a higher level, I'd say it's worth considering the > audience we want to focus on. For veteran (Emacs) Lisp > programmers, new additions like 'pcase' can increase the > difficulty of reading new Elisp code: your prior mastery of > the language isn't any good when you hit that "(pcase". > However, many programmers today don't know Lisp, of any > variety. For people like that, learning to contribute to > Emacs means learning from the very beginning. Having gone > through this, most of 'pcase' was very easy for me to pick > up, and other parts of Elisp were much more challenging (it > took me a long time to get comfortable with writing macros, > which is also probably one of the reasons I found > 'pcase-defmacro' to be so tricky). > > That said, it's true that every feature we add to Elisp > increases the overall complexity because now there are more > things to learn. However, in my opinion, the expressiveness > of 'pcase' far outweighs this cost. Well said! Thank you for this post. I agree, and I enjoyed reading it. -- underground experts united https://dataswamp.org/~incal