From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Re: Adding package "Loopy" to Non-GNU Devel? Date: Tue, 20 Feb 2024 08:09:32 +0000 Message-ID: <87wmqz1rr7.fsf@posteo.net> References: <871ec398-df6a-44a1-a149-d0014f99b756@protonmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20898"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Okamsn Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Feb 20 09:10:36 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 1rcLD0-0005EU-Id for ged-emacs-devel@m.gmane-mx.org; Tue, 20 Feb 2024 09:10:34 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcLC8-0004Tg-D8; Tue, 20 Feb 2024 03:09:41 -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 1rcLC6-0004TF-0L for emacs-devel@gnu.org; Tue, 20 Feb 2024 03:09:38 -0500 Original-Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcLC3-0000jF-T7 for emacs-devel@gnu.org; Tue, 20 Feb 2024 03:09:37 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 6F7AA240103 for ; Tue, 20 Feb 2024 09:09:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1708416573; bh=V0k4vap5TakcG7ekEq1abUeHjzSYan3+kBsq0qLZE74=; h=From:To:Cc:Subject:OpenPGP:Date:Message-ID:MIME-Version: Content-Type:From; b=ONQwiIQEJQBI5+oQNH99X8IX+nRFC4FvRN68Usv/DADqMOQABLWnUTs9S3P/6L+Q6 1Hv1xK39JAbdaj/KbqFUlWvwxIw95bkUw1QAvoUe49Lozs+hKmaSJFmg3NLgUGYvwQ Z7MnAY0eDhRSnhwIRoGh/Mc766JMMuECIkgvgVkl3qVoJvpHRf+g06qSXFkGgKrstW yC+JfyNeIGQKWhNB5h5NYJIF6gBOswzhkVmtxeNHuw1JKh+6TGaNuUVP862RIHfk7W p7xkmKjuf9K3BCxMtGrdpHup/mKUGF3YSqzwCmYAVi0X8itPNGnqxT7NHLlQcdRm6I +ZGS0cH8ZP0qA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4TfBrr6MLYz9rxF; Tue, 20 Feb 2024 09:09:32 +0100 (CET) In-Reply-To: <871ec398-df6a-44a1-a149-d0014f99b756@protonmail.com> (okamsn@protonmail.com's message of "Tue, 20 Feb 2024 02:15:16 +0000") OpenPGP: id=7126E1DE2F0CE35C770BED01F2C3CC513DB89F66; url="https://keys.openpgp.org/vks/v1/by-fingerprint/7126E1DE2F0CE35C770BED01F2C3CC513DB89F66"; preference=signencrypt Received-SPF: pass client-ip=185.67.36.66; envelope-from=philipk@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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:316392 Archived-At: Okamsn writes: > Hello, > > I am the author of the package "loopy", which provides macros similar to > ~cl-loop~ and Common Lisp's =iterate=. It is located here: > > https://github.com/okamsn/loopy (Obligatory question here, as to why we don't also name the package iterate?) > For those not willing to browse GitHub, I have copied the main points > from the > README.org file. I have attached the README and the Org documentation file. > > Visually, Loopy differs by using parentheses instead of keywords like > ~cl-loop~. > For example, > > #+begin_src emacs-lisp > ;; A use of `cl-loop': > (cl-loop for i from 1 to 10 > if (cl-evenp i) collect i into evens > else collect i into odds > end ; This `end' keyword is optional here. > finally return (list odds evens)) > > ;; How it could be done using `loopy': > (loopy (numbers i :from 1 :to 10) > (if (cl-evenp i) > (collect evens i) > (collect odds i)) > (finally-return odds evens)) > #+end_src > > Non-visually, these are I think the main improvements: > > - Better destructuring than =cl-lib=, in that it can destructure arrays and > supports destructuring in accumulations (like ~collect~) as well as in > iteration. I recently added a Pcase pattern for this outside of the > ~loopy~ macro. > > #+begin_src emacs-lisp > ;; => (8 10 12 14 16 18) > (loopy (list list-elem '(([1 2 3] [4 5 6]) > ([7 8 9] [10 11 12]))) > (sum ([sum1 sum2 sum3] [sum4 sum5 sum6]) > list-elem) > (finally-return sum1 sum2 sum3 sum4 sum5 sum6)) > #+end_src Where is pcase being used here? > > - Better control over accumulations, in that one can declare that an > accumulation is "optimized" (for example, using the ~push~-~nreverse~ > pattern > instead of the ~append~-~list~ pattern) for named variables, allowing to > efficiently accumulate for multiple values and to declare beforehand > whether > adding to the front or the end of the list should be preferred. > > The below expands into two instances of the ~push~-~nreverse~ pattern: > > #+begin_src emacs-lisp > ;; Separate the elements of sub-list: > ;; => ((1 3) (2 4)) > (loopy (accum-opt elem1 elem2) > (list i '((1 2) (3 4))) > (collect (elem1 elem2) i) > (finally-return elem1 elem2)) > #+end_src > > > - A way to embed the looping constructs in arbitrary code like in Common > Lisp's > Iterate: > > #+begin_src emacs-lisp > (require 'loopy-iter) > > ;; Things to note: > ;; => ((-9 -8 -7 -6 -5 -4 -3 -2 -1) > ;; (0) > ;; (1 2 3 4 5 6 7 8 9 10 11)) > (loopy-iter (accum-opt positives negatives zeroes) > (numbering i :from -10 :to 10) > ;; Normal `let' and `pcase', not Loopy constructs: > (let ((var (1+ i))) > (pcase var > ((pred cl-plusp) (collecting positives var)) > ((pred cl-minusp) (collecting negatives var)) > ((pred zerop) (collecting zeroes var)))) > (finally-return negatives zeroes positives)) > #+end_src > > > - An =at= feature to manipulate containing loops, such as moving to the next > iteration step or accumulating into a variable: > > #+begin_src emacs-lisp > (loopy outer > (array i [(1 2) (3 4) (5 6)]) > (loopy (with (sum (apply #'+ i))) > (list j i) > (at outer (collect (+ sum j))))) > #+end_src > > - It should be easy to add new looping features. The documentation has > examples of this. > > > The package and an extension package (to use Dash's destructuring instead of > that of Loopy, Pcase, or Seq) has been available on MELPA for a few > years now. > I am asking about Non-GNU Devel instead of just the normal Non-GNU archive > because I am still making breaking changes to the package as I reduce > duplication and improve on the ideas, but those changes are coming less > frequently now. If you want to prevent a package from being released, you just need to make sure keep some negative version suffix like -rc in the version tag. But in general, I wouldn't advise regarding NonGNU ELPA devel as a proper package archive for users, but more as a preview for developers to see how the ELPA build server is processing your package. Or that is at least my take. > Is it possible to add this package and the extension package to the archive? > > I keep the extension package in the same GitHub repo as the main package for > testing purposes. The Dash functionality was requested by a user, but > Dash is > not used by the rest of the package. Because of that, I put the Dash > functionality in a small separate package. You are talking about the loopy-dash.el file in the same branch, right? If possible, it would be better if you could at least maintain it in a separate branch. > Thank you.