From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: "Alfred M. Szmidt" Newsgroups: gmane.emacs.devel Subject: Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs] Date: Sat, 09 May 2020 13:35:52 -0400 Message-ID: References: <0c88192c-3c33-46ed-95cb-b4c6928016e3@default> <87wo5mc04t.fsf@fastmail.fm> Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="90397"; mail-complaints-to="usenet@ciao.gmane.io" Cc: joostkremers@fastmail.fm, rms@gnu.org, emacs-devel@gnu.org To: Philippe Vaucher Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat May 09 19:37:27 2020 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 1jXTPj-000NQ7-KK for ged-emacs-devel@m.gmane-mx.org; Sat, 09 May 2020 19:37:27 +0200 Original-Received: from localhost ([::1]:50428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXTPi-0000ky-6W for ged-emacs-devel@m.gmane-mx.org; Sat, 09 May 2020 13:37:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXTOG-00074f-2B for emacs-devel@gnu.org; Sat, 09 May 2020 13:35:57 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:56354) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXTOF-0004QP-PA; Sat, 09 May 2020 13:35:55 -0400 Original-Received: from ams by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1jXTOC-0004ZU-5B; Sat, 09 May 2020 13:35:52 -0400 In-Reply-To: (message from Philippe Vaucher on Sat, 9 May 2020 17:30:45 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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:249519 Archived-At: > Can you give some examples of using dash.el? Let's start with a disclaimer: it's hard to come with examples on the spot. Also because I usually code with dash or seq it's hard for me to know the real "plain emacs lisp" equivalent. I understand, and I wasn't really expecting an example so soon, so thank you for taking the time to do it. I was hoping for examples of the more complicated constructs, like the threading ones not the anaphoric variants. (let ((lst '(1 2 3 4))) (pp (--map-when (= it 2) 17 lst)) (pp (mapcar (lambda (it) (if (= it 2) 17 it)) lst))) The point here is that the first one almost reads like english. The intention is very clear (to me). The "pure lisp" one I have to put more attention to it. I guess you'll disagree :-) I guess it is because you are more used to the abstraction level. I find the later to be much more natural to write. It also lends it self much easier (I think) if you wish to modify it at some later point, e.g., you put the lambda in a function. I do not see what is won here won in this case, you write code only once -- you read it much more. If the lambda does something remotley complicated, you would want to put it in a seperate function (either defun, or flet). This leads to easier testing and experimenting/debugging too, since in both cases (lambda or named function) you can use it as a normal form. That isn't true for the first example. (let ((lst '("1" 2 "3" 4)) (delme (make-symbol "delme"))) (pp (--remove (and (numberp it) (= it 2)) lst)) (pp (delete delme (mapcar (lambda (it) (if (and (numberp it) (= it 2)) delme it)) lst)))) Yes, I now I can use cl-remove-if or seq-remove, but I think it further illustrates the point: I see both seq- and cl- as attempts at fixing the Emacs api that was lacking. If I'm not mistaken seq.el was even inspired by dash. Why even do that! You could just use `delq`: (delq 2 '("1" 2 "3" 4)) The more I think about it, it seems that people aren't looking to learn Emacs Lisp -- but rather they want to learn Haskell/Clojure/...? In many languages, "flatten" is a basic concept. You'd expect something as basic to be in the language... flatten-list? Now that I said all this, FWIW I'd agree that because there is seq- and map- we don't really need dash- anymore in Emacs core for a lot of use cases. Maybe the anaphoric/threading functions would be nice but I doubt they'd interest you. Examples of threading: Do not assume that! It is the threading ones that I was _specifically_ interested in, since they are non-trivial in behaviour. Anaphoric functions are boring, they are trivial and only muddle the viewable code. I personally dislike them immensly since they bind an implicit variable that you cannot easily see as a reader of the code.