[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: |
Richard Stallman |
Subject: |
Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs] |
Date: |
Sat, 09 May 2020 22:33:43 -0400 |
[[[ 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. ]]]
Thanks for showing me examples of dash.el. A lot of these facilities
seem useful. I would very much like to see the _documentation_ for how
to use it.
First, these all seem to be macros, right?
Why do some names start with a single dash and some with a double dash?
About --map-when:
> (let ((lst '(1 2 3 4)))
> (pp (--map-when (= it 2) 17 lst))
> (pp (mapcar (lambda (it) (if (= it 2) 17 it)) lst)))
The map-when version was not self-evident to me.
I had to read the mapcar version to understand its meaning.
Once I did that, it made sense, and I can see that it is useful.
I think we should add this to Emacs, but with a couple of changes.
* Call it 'map-when' -- why use dashes?
* Change the calling convention syntax to (map-when ((= it 2) 17) lst)
simply so it easier to see what groups with what.
That gives it the structure of the inside of a cond.
About --remove:
That is good as is, I would just call it 'remove-if'.
> I was going to make an example with `-flatten` but I think this page
> is better showing my point:
>
https://stackoverflow.com/questions/969067/name-of-this-function-in-built-in-emacs-lisp-library
I will fetch that page and look at it.
(->> '(1 2 3) (-map 'square) (-remove 'even?)) ;; => '(1 9)
Is '-map' just another name for 'mapcar'?
After some effort I figured out what that example is doing, I think.
Indeed, it can be used. At the same time, what advantage is that
supposed to provide over writing it the Lisp way?
(remove-if 'evenp (mapcar 'square '(1 2 3)))
About -->:
(--> "def" (concat "abc" it "ghi") (upcase it)) ;; => "ABCDEFGHI"
This sort of shorthand for binding a variable can make code simpler.
The name could be a good one, if there are only a few such constructs
and each one of them acts at the very general level of this one.
Do poeple see any practical problem that would result from the name -->?
--
Dr Richard Stallman
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], (continued)
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Dmitry Gutov, 2020/05/09
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Richard Stallman, 2020/05/10
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Joost Kremers, 2020/05/11
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], tomas, 2020/05/11
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Philippe Vaucher, 2020/05/11
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], tomas, 2020/05/11
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Philippe Vaucher, 2020/05/11
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], 조성빈, 2020/05/11
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Joost Kremers, 2020/05/11
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Philippe Vaucher, 2020/05/11
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs],
Richard Stallman <=
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Philippe Vaucher, 2020/05/10
- RE: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Drew Adams, 2020/05/10
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Philippe Vaucher, 2020/05/10
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Alfred M. Szmidt, 2020/05/10
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Phillip Lord, 2020/05/11
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Stefan Monnier, 2020/05/10
- RE: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Drew Adams, 2020/05/10
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Richard Stallman, 2020/05/10
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Richard Stallman, 2020/05/10
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Phillip Lord, 2020/05/11