[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Clojure-like syntactic sugar for an anonymous function liter
From: |
Lars Ingebrigtsen |
Subject: |
Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal |
Date: |
Sun, 25 Jan 2015 10:33:47 +1100 |
User-agent: |
Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux) |
Daniel Colascione <address@hidden> 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)
>
> 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 it either, but perhaps it's a good idea anyway?
1) I really like the way that Lisp has a culture of making explicit
bindings. Naming variables helps a lot with reading comprehension,
which is a pretty important thing.
In these toy examples it doesn't make much difference, but that's not
how real code looks like. In real code you have ten-line lambdas with
the "%" appearing on the second-to-last line, and you will have
forgotten what that "%" refers to when you reach that line.
And the forms are awfully kludgey, since they don't really nest that
well.
2) The Kids These Days really love this way of writing code. I mean,
kids have always loved write-only obfuscatory code, but they seem to
have really glommed on to this idiom of implicit parameters in
closures.
Perhaps part of that is just that there are so many programmers forced
to work in the Java industry, and they only have the choice of working
with the dreary drudgery of actual Java code, the incomprehensibility of
Scala, and the (in comparison) sanity of Clojure. And the Clojure peeps
really like that style, it seems.
So to make Emacs Lisp more attractive to the incoming locust of Clojure
programmers, perhaps we should accommodate that by adding these forms?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog http://lars.ingebrigtsen.no/
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, (continued)
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, David Kastrup, 2015/01/22
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Oleh, 2015/01/22
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Daniel Colascione, 2015/01/22
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Oleh, 2015/01/22
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Daniel Colascione, 2015/01/22
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Oleh, 2015/01/22
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Daniel Colascione, 2015/01/22
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Oleh, 2015/01/22
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Ivan Andrus, 2015/01/22
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Leo Liu, 2015/01/22
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal,
Lars Ingebrigtsen <=
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Stephen J. Turnbull, 2015/01/22
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, David Kastrup, 2015/01/22
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Stephen J. Turnbull, 2015/01/22
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Oleh, 2015/01/22
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Stephen J. Turnbull, 2015/01/22
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Oleh, 2015/01/22
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, David Kastrup, 2015/01/22
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Oleh, 2015/01/22
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Tassilo Horn, 2015/01/22
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Oleh, 2015/01/22