emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs]


From: Alfred M. Szmidt
Subject: Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs]
Date: Sat, 09 May 2020 13:35:52 -0400

   > 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]