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: Daniel Colascione
Subject: Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal
Date: Thu, 22 Jan 2015 01:38:28 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

On 01/22/2015 01:27 AM, Oleh wrote:
>> Anonymous lambdas become considerably more useful once you have lexical
>> scoping.  The latter has not been around long enough to have had a major
>> impact on Elisp programming styles yet.
>>
>> That does not mean that I am convinced we want or need short-lambda.
> 
> 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)

With idiomatic elisp, it's

  (mapcar (lambda (x) (* x x)) '(1 2 3))

Both alternatives above are more esoteric than the lambda form and are
approximately as wrong.  Note how the "lambda" is a prominent "I AM A
FUNCTION" signal.  I don't like the shorter forms, won't use them in my
code, and wouldn't rely on calling packages. I don't want to change the
Emacs reader to support this syntax.

That said, I would like CL-style reader macros. I can't stop you from
using reader macro support to implement your kind of function literal.
The proliferation of overly-clever code like the above two snippets is a
cost I am willing to bear for having reader macros macros.

> I've grepped the useage of `--map' in all > 150 third party packages
> that depend on `dash'.
> I got 203 total results 60 different packages. This says a lot about
> people wanting this feature for a long time.

No it doesn't: you didn't provide a baseline. Allow me.

~/edev/trunk/lisp
$ ppgrep -w '(lambda' | wc -l
6834

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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