emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Clojure-like syntactic sugar for an anonymous function liter


From: Oleh
Subject: Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal
Date: Thu, 22 Jan 2015 11:22:42 +0100

>  > 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.

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.

On the other hand, `mapcar' is a C function. It and all other
functions can use `short-lambda' instead of being reimplemented as
macros on a case-per-case basis by `dash'.



reply via email to

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