From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: phillip.lord@newcastle.ac.uk (Phillip Lord) Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal Date: Thu, 22 Jan 2015 11:03:33 +0000 Message-ID: <87zj9b6pru.fsf@newcastle.ac.uk> References: <54C05269.7050602@dancol.org> <87oaprfa3t.fsf@fencepost.gnu.org> <877fwfunnz.fsf@uwakimon.sk.tsukuba.ac.jp> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1421924672 2440 80.91.229.3 (22 Jan 2015 11:04:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 22 Jan 2015 11:04:32 +0000 (UTC) Cc: Oleh , "emacs-devel@gnu.org" To: "Stephen J. Turnbull" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 22 12:04:31 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YEFYt-0001gt-AE for ged-emacs-devel@m.gmane.org; Thu, 22 Jan 2015 12:04:31 +0100 Original-Received: from localhost ([::1]:52293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEFYn-000696-Fi for ged-emacs-devel@m.gmane.org; Thu, 22 Jan 2015 06:04:25 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEFY8-0005SP-Lj for emacs-devel@gnu.org; Thu, 22 Jan 2015 06:03:45 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEFY2-0002FB-PW for emacs-devel@gnu.org; Thu, 22 Jan 2015 06:03:44 -0500 Original-Received: from cheviot22.ncl.ac.uk ([128.240.234.22]:50814) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEFY2-0002BV-K5 for emacs-devel@gnu.org; Thu, 22 Jan 2015 06:03:38 -0500 Original-Received: from smtpauth-vm.ncl.ac.uk ([10.8.233.129] helo=smtpauth.ncl.ac.uk) by cheviot22.ncl.ac.uk with esmtp (Exim 4.63) (envelope-from ) id 1YEFXx-0005GC-F9; Thu, 22 Jan 2015 11:03:33 +0000 Original-Received: from jangai.ncl.ac.uk ([10.66.67.223] helo=localhost) by smtpauth.ncl.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1YEFXx-0003n1-Bh; Thu, 22 Jan 2015 11:03:33 +0000 In-Reply-To: <877fwfunnz.fsf@uwakimon.sk.tsukuba.ac.jp> (Stephen J. Turnbull's message of "Thu, 22 Jan 2015 19:15:12 +0900") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 128.240.234.22 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:181585 Archived-At: "Stephen J. Turnbull" writes: > Oleh writes: > > > The most popular library in MELPA, https://github.com/magnars/dash.el, > > implements it (for a long time) like this: > > > > (--map (* it it) '(1 2 3)) > > ;; => (1 4 9) > > > > With my approach, it's: > > > > (mapcar #(* % %) '(1 2 3)) > > ;; => (1 4 9) > > That looks almost like Perl! Now I'm -2. Just require dash. It is an open question with clojure as well how often to use this syntax as opposed to Clojure's lambda. I tend to prefer the lambda syntax because (ironically) it is capable to being de-anonymised; so all of these do the same thing: #(%) (fn [y] y) (fn x [y] y) but the last one gives easier to read stack traces. In practice, though, the shorthand syntax does not tend to produce overly perl-like code; it is a self-limiting syntax, since it does not nest. My first impression of Clojure was that it had too much syntactic-sugar, but having used it a lot now, I tend to appreciate it more. I miss the explicit map notation most of all in elisp. Phil