emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Improve `replace-regexp-in-string' ergonomics?


From: Lars Ingebrigtsen
Subject: Re: Improve `replace-regexp-in-string' ergonomics?
Date: Wed, 22 Sep 2021 22:06:41 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (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.)

Yeah, you really need something like that to actually do threading in a
Lispish language.  But it feels very hackish indeed.  Example from the
man page:

(as-> owners $ (nth $ 0) (:pets $) (deref $) ($ 1) ($ :type))

It's like...  revenge of the Perl.

Threading works a lot better in languages that are designed around it --
i.e., languages that have a consistent parameter placement, and doesn't
have optional parameters.  (Instead they introduce new functions when a
Lispish language introduces an optional parameter.)

Threading feels more like a neat hack in Lispish languages than actually
useful.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



reply via email to

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