From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oleh Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal Date: Thu, 22 Jan 2015 12:03:37 +0100 Message-ID: References: <54C05269.7050602@dancol.org> <87oaprfa3t.fsf@fencepost.gnu.org> <877fwfunnz.fsf@uwakimon.sk.tsukuba.ac.jp> <877fwfgk2x.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1421924651 1872 80.91.229.3 (22 Jan 2015 11:04:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 22 Jan 2015 11:04:11 +0000 (UTC) To: Oleh , "Stephen J. Turnbull" , "emacs-devel@gnu.org" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 22 12:04:06 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 1YEFYO-0001RV-NG for ged-emacs-devel@m.gmane.org; Thu, 22 Jan 2015 12:04:00 +0100 Original-Received: from localhost ([::1]:52287 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEFYN-0005SQ-Lv for ged-emacs-devel@m.gmane.org; Thu, 22 Jan 2015 06:03:59 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38002) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEFY3-0005SJ-Bt for emacs-devel@gnu.org; Thu, 22 Jan 2015 06:03:44 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEFY2-0002EY-Ek for emacs-devel@gnu.org; Thu, 22 Jan 2015 06:03:39 -0500 Original-Received: from mail-wi0-x229.google.com ([2a00:1450:400c:c05::229]:65213) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEFY2-0002EJ-8K for emacs-devel@gnu.org; Thu, 22 Jan 2015 06:03:38 -0500 Original-Received: by mail-wi0-f169.google.com with SMTP id bs8so39431475wib.0 for ; Thu, 22 Jan 2015 03:03:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=qmNGOS6KbdppxwtVkgrXG/lG/Tni8+MNOXFLPH5CanU=; b=MMirzTm4r5/GYpoC3/Oy408HOs9n9xpSSuxsxJqu7LdY+f9RPdlvVu4BG7XNOUK77J zkcvc1FMc5ky1lBsSCg6gY9qBfdz7X0e0FYdnNicQKedWrh+7tYzhqhgXb85Y6bBwg2S H5QE9qkbOSsrRctSZOKuQ3G8k+JEY8vD3CxiM8zh+cIs+RjtDm2QAcoI14a5UPEnLm4O EXOd+100W3/UcQbTi9ewBNNJL9EqMu+P9xqD264JYZKMlKA/TpIhsf5QvP0B1lWz8qpX pTZws9ZIZiUCe+ijhDJywE8Bd88AqohPRKVLX6QVaw2EKewfMSTe3DsSFGhiRJ7dicNB W/8Q== X-Received: by 10.194.234.2 with SMTP id ua2mr1895341wjc.40.1421924617624; Thu, 22 Jan 2015 03:03:37 -0800 (PST) Original-Received: by 10.27.137.137 with HTTP; Thu, 22 Jan 2015 03:03:37 -0800 (PST) In-Reply-To: <877fwfgk2x.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::229 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:181584 Archived-At: >> How is `dash' better? `--map' is a macro: >> >> (defmacro --map (form list) >> "Anaphoric form of `-map'." >> (declare (debug (form form))) >> `(mapcar (lambda (it) ,form) ,list)) >> >> `dash' also gives other ~40 macros that look like this, littered all >> over the code in the MELPA, so it's impossible to go on without >> understanding what `dash' does. > > FWIW, I favor your Clojure-like syntax over anaphoric macros. And one > benefit is that you're not restricted to one list to map over as in > --map. E.g., your approach works out of the box with > > (cl-mapcar #(- %5 %4 %3 %2 %1) list1 list2 list3 list4 list5) > > for which there is no dash equivalent. Of course, --map could be > extended to create args (it1 ... itN) if more than one list is given. > > BTW, do you also support %& to declare that the lambda has a &rest arg > so that you can do > > (apply #'cl-mapcar #(apply #'- (reverse %&)) list-of-lists) > > ? Yes, this is works: (apply #'cl-mapcar #(apply #'- (reverse %&)) '((2 4 10) (4 5 6))) ;; => (2 1 -4) shortly: (short-lambda (apply (function -) (reverse %&))) ;; => (lambda (&rest %&) (apply (function -) (reverse %&)))