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: Sun, 17 Apr 2022 18:09:24 -0400 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="1250"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Apr 18 00:10:37 2022 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 1ngD6L-0000Bj-PI for ged-emacs-devel@m.gmane-mx.org; Mon, 18 Apr 2022 00:10:37 +0200 Original-Received: from localhost ([::1]:34210 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ngD6K-0001QT-Ar for ged-emacs-devel@m.gmane-mx.org; Sun, 17 Apr 2022 18:10:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ngD5L-0000jL-0x for emacs-devel@gnu.org; Sun, 17 Apr 2022 18:09:35 -0400 Original-Received: from mail-qk1-x72c.google.com ([2607:f8b0:4864:20::72c]:42876) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ngD5J-0000Wb-7p; Sun, 17 Apr 2022 18:09:34 -0400 Original-Received: by mail-qk1-x72c.google.com with SMTP id j6so10134658qkp.9; Sun, 17 Apr 2022 15:09:32 -0700 (PDT) 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=rLAhR5/9SeuTxOP2+9SwDmTEYoO+pnjT3nnh3KkOIkU=; b=QJP9JdjCUe/3NDSjwC1in/tfVx7UyLqGURFSkAeUq7JZiu4T9ZooniUuTwajKL3As9 h3IkxlpNJdrchk8Mqdpt/WOBSHrvBtRw0DB1Tja6vimQsnwSnTwQyXwLcDC4VOaJf9xf 1UiFova3YVRUl7pax7aBVouuj9CO6hxx3KhPE6K/qMmRs97+mOh0/uLBs46Vd/4H12vP r+E0v4QxsBkKJGZ9yeFXUpobkEeMYV6/xrX6dFcMD/BsjQyw4rpPR/QzppaME6UFIBR2 eI4KwxQ6qiBEGV8eVSEQ174EsZNT9eYMMfjo+35V63i0/vLo41QEcoHA2nh8O4nN+m+o spMw== 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=rLAhR5/9SeuTxOP2+9SwDmTEYoO+pnjT3nnh3KkOIkU=; b=jlmY8LNGdrEFIxbTvFSJ0ZOVcuuuQujfE5xQk4ceywzmbopSjJQgcZnqXu7hpqNyX0 edGwfu1OzjX8ROpvkbZ1udyLeLyaL0VyXJZae7VDYxQGMZSH6OTAA59e/zs3SWGZnrx0 jXS5SE5jhd/TcHTn7hIITQlD78mz+bxf9H4auUtoWHDn+NNGD2BUlsyt2/boYrJU49Vy AeNECHJ2kkWrkb6ut/vmnFk1kQAwWfVkgffyvwOgJkILy8qHtOWumDqx9h+1lH0BhL8o REmEZ40dx+jedHuFsEIDSJTb3lgi9xCjT2d508FXW8p9ImaQf/eGldcHqvEqckK6njTu BsGQ== X-Gm-Message-State: AOAM530CLxL9hLXWnw3XU856NRHtIhAW/NE0A3Mq6LELGJZUlgLA/8yg RPwzwsRa8zK0oY89M3ChcT1f3l2L8MD3Tw== X-Google-Smtp-Source: ABdhPJyNP8/n24w531h0VykJLflt1VxpdVDqGUvuqhypcWjUe/o4Jnd5MQtrxhVw5/mH3k1avsj6uQ== X-Received: by 2002:a37:b984:0:b0:67f:64a2:313e with SMTP id j126-20020a37b984000000b0067f64a2313emr4948508qkf.3.1650233371273; Sun, 17 Apr 2022 15:09:31 -0700 (PDT) Original-Received: from andrews-mbp.lan (pool-173-56-75-166.nycmny.fios.verizon.net. [173.56.75.166]) by smtp.gmail.com with ESMTPSA id g21-20020ac85815000000b002e06e2623a7sm6761455qtg.0.2022.04.17.15.09.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Apr 2022 15:09:30 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::72c; envelope-from=ahyatt@gmail.com; helo=mail-qk1-x72c.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" Xref: news.gmane.io gmane.emacs.devel:288579 Archived-At: On Thu, Mar 31, 2022 at 12:27 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. ]]] > > > The way I look at it, it does do this, but it's just > > structured differently. The normal defun as one arglist. > > Mine has one per matching clause, which means that it can > > take a variety of different arguments, all matching. And > > the arglist and the matching clauses are the same thing, so > > the arglist can be (n), or ('foo n), or (1 2 (3 n)), etc. > > Yes, it's weird, but I think the differentiation here is > > useful, see my next point. > > The argument list is not just a concept in users' minds. The > command C-h f, which shows documentation for a function, > displays the function's argument list. If you try C-h f cons > RET, you'll see what I mean. > > See also `func-arity'. > > So there is a practical reason for defining constructs to set up > the function's argument list. > > > In particular, with your proposal, we lose the ability to > > have fairly different arg patterns, with different numbers > > of args, or different destructuring patterns. > > Not necessarily. You could specify `&rest args' for an arglist > that conveys no information. But users find it useful to see in > a simple way what the arguments of the function should be. Thanks for the suggestion. I've implemented a new version along the lines you suggested. So now things look like: (defun-pattern fibonacci (n) "Compute the fibonacci sequence." (0 0) (1 1) (n (+ (fibonacci (- n 1)) (fibonacci (- n 2))))) and (defun-pattern repeatedp (&rest args) "Test for repeated pattern, returns nil, 'once, or 'twice, or 'split." ((a a) 'once) ((a a a) 'twice) ((a b a) 'split)) With this, I think I've answered your objections. Do you have an opinion on what I should do with this? I can check this in the emacs source code, as a GNU elpa package, or just put it in an external repository. > > > -- > 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)