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: Sun, 11 Dec 2016 19:41:26 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Clément Pit--Claudel <address@hidden> writes:

>> (with-format ((zot "foo")
>>               (thing (funcall '+ 3.42423 4)))
>>   "This is %{thing}.2f and %{zot}ss")
>
> This looks fine too, but the repetition bothers me (I don't really see what 
> benefit there is to naming all arguments).  So I still find
>
>   "This is %(funcall '+ 3.42423 4).2f and "foo"s"
>
> more readable.

Yeah, the repetition isn't nice, but it's all a choice of how explicit
and how little magic you want to have.  In the `with-format' you're
taking things explicitly out of the lexical/dynamic space the values may
live in an put it into the lexical form.

The other approach I mentioned is less explicit:

(fmt "This is %{thing}.2f and %{zot}ss"
     (thing (funcall '+ 3.42423 4)))

If the named parameter mentioned isn't part of the value alist, then
it's taken as a variable in its lexical/dynamic space, but if it does,
then we use the value provided in the alist.

Lisp has traditionally erred on the side of explicitness, but there's a
movement towards more magic these days.

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