From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs] Date: Sat, 09 May 2020 22:33:43 -0400 Message-ID: References: <0c88192c-3c33-46ed-95cb-b4c6928016e3@default> <87wo5mc04t.fsf@fastmail.fm> Reply-To: rms@gnu.org Content-Type: text/plain; charset=Utf-8 Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="34910"; mail-complaints-to="usenet@ciao.gmane.io" Cc: joostkremers@fastmail.fm, ams@gnu.org, emacs-devel@gnu.org To: Philippe Vaucher Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun May 10 04:36:25 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 1jXbpI-0008ys-7z for ged-emacs-devel@m.gmane-mx.org; Sun, 10 May 2020 04:36:24 +0200 Original-Received: from localhost ([::1]:38618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXbpH-00045J-AJ for ged-emacs-devel@m.gmane-mx.org; Sat, 09 May 2020 22:36:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42506) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXbmr-0008SI-2n for emacs-devel@gnu.org; Sat, 09 May 2020 22:33:53 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:36097) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXbmq-0004Xy-Mw; Sat, 09 May 2020 22:33:52 -0400 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1jXbmh-0002qN-KF; Sat, 09 May 2020 22:33:43 -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:249627 Archived-At: [[[ 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)