[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Improve `replace-regexp-in-string' ergonomics?
From: |
Adam Porter |
Subject: |
Re: Improve `replace-regexp-in-string' ergonomics? |
Date: |
Wed, 22 Sep 2021 03:21:17 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) |
Augusto Stoffel <arstoffel@gmail.com> writes:
> Clojure has a moderately useful named variant of the threading macro for
> this kind of situation:
>
> (as-> expr name & forms)
>
> Binds name to expr, evaluates the first form in the lexical context
> of that binding, then binds name to that result, repeating for each
> successive form, returning the result of the last form.
>
> (I guess I would have chosen the opposite order of the 'expr' and 'name'
> arguments, though.)
Agreed, I'd be happy to have a `thread-as' macro, used like:
(thread-as NAME EXPR &rest FORMS)
I considered proposing one recently, but it seems like anaphoric macros
aren't popular around here. :) Sometimes they really are the best way
to simplify code, since not all functions work with `thread-last' or
`thread-first'.
Re: Improve `replace-regexp-in-string' ergonomics?, Lars Ingebrigtsen, 2021/09/22
Re: Improve `replace-regexp-in-string' ergonomics?, Dmitry Gutov, 2021/09/22
Re: Improve `replace-regexp-in-string' ergonomics?, Stefan Monnier, 2021/09/22