[Top][All Lists]

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

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

From: Phillip Lord
Subject: Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal
Date: Thu, 22 Jan 2015 11:03:33 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

"Stephen J. Turnbull" <address@hidden> 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.


reply via email to

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