GNU bug report logs -
#56875
29.0.50; [PATCH] Add thread-as macro
Previous Next
Reported by: Augusto Stoffel <arstoffel <at> gmail.com>
Date: Mon, 1 Aug 2022 17:08:02 UTC
Severity: wishlist
Tags: moreinfo, patch, wontfix
Found in version 29.0.50
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
It has been noted many times that threading macros are not as useful in
Emacs Lisp because the APIs are not always consistent with regard to the
ordering of arguments. A “thread-as” macro on the lines of Clojure's
'as->' [1] would address this difficulty.
The signature of the Clojure macro is (as-> expr name & forms), which
looks a bit odd to me. Here I've changed this so the lexical variable
(name) comes before the initial value (expr).
Also, unlike thread-first and thread-last, in the attached version of
the macro there's no magic whereby an element of FORMS which is a
symbol, say fun, is turned into a function call, i.e. (fun name). In
other words, (thread-as x 1 1+) returns the symbol 1+. Clojure
behaves the same. I'm not necessarily against changing the macro so
that the above example returns 2, but I don't see a good reason to do
so either; for one thing, the example gives a byte-compilation warning
(unused lexical variable x).
[1]: https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/as-%3E
[0001-Add-thread-as-macro.patch (text/x-patch, attachment)]
This bug report was last modified 2 years and 267 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.