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: Joost Kremers
Subject: Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs]
Date: Sun, 10 May 2020 02:02:42 +0200
User-agent: mu4e 1.4.4; emacs 27.0.91


On Sun, May 10 2020, Alfred M. Szmidt wrote:
[threading macros]
In these cases, I see absolutley no benefit of using ->, it just makes it more "magical" for no particular reason.

For sure, whether to use a threading macro is a large part personal preference, but IMHO they *can* make code more readable. Basically, you can convert:

  (print (eval (read)))

into:

   (-> (read)
     eval
     print)

The first form is backwards, in a way: `print` is written first, but it's what happens last. With `->` you can write the functions in the order in which they're executed.

For a longer discussion with more examples, see here: <https://yoo2080.wordpress.com/2014/02/23/threading-macros-from-dash-for-emacs-lisp/>

And I don't think it's been pointed out yet (though I may have missed some messages in this thread), that `->` and `->>` are part of Elisp since Emacs 25, except that they are called `thread-first` and `thread-last` (somewhat unfortunately, I believe, because they have nothing to do with CPU threads and are therefore unrelated to the other Elisp functions whose names start with `thread-`.)


--
Joost Kremers
Life has its moments



reply via email to

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