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 12:03:37 +0100

>> 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 %&)))



reply via email to

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