emacs-devel
[Top][All Lists]
Advanced

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

Re: RFC: String interpolation


From: Lars Ingebrigtsen
Subject: Re: RFC: String interpolation
Date: Mon, 12 Dec 2016 18:12:36 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

If we take one step back and look at our objectives and options here,
this is how I see it:

1) It is somewhat attractive to be able to drop variables into
formatting strings: Quite a lot of popular programming languages allow
this.

2) It is not that attractive to extend this to general programming
constructs, because code inside strings is just ... bad.

4b) But people sometimes need to tweak the look of the values before they
are printed, and forcing people to switch between paradigms is also bad.

4d) Introducing new variables, or values visible outside of the
formatting statement is bad, because things that belong inside the
formatting statement belong inside, not outside (for readability and
maintainability).

Solution:

Allow 1), and provide 4b) by putting the extra code inside the
formatting statement, but not inside the string itself.

Ergo:

(fmt "This is %{thing}s and %{zot}.2f"
     :thing (replace-regexp-in-string " +" " " thing))

If, however, you don't mind 4d) at all, and think that introducing new
bindings is a spiffy way to do programming (shades of the fabulous
interface that `url-retrieve' has now), then I guess I can't really say
much more than: ¯\_(ツ)_/¯

-- 
(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]