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: Wed, 14 Dec 2016 00:55:17 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Paul Eggert <address@hidden> writes:

>       (message (concat "Clock stopped at %s after "
>                        (org-minutes-to-clocksum-string (+ (* 60 h) m))
> "%s")
>                te (if remove " => LINE REMOVED" ""))
>
> could be rewritten this way:
>
>       (message "Clock stopped at %s%" te
>                " after %s%" (org-minutes-to-clocksum-string (+ (* 60 h) m))
>                "%s" (if remove " => LINE REMOVED" ""))

I've been trying out this syntax a bit (just rewriting a few statements
to see whether they look better or worse than the old statements :-)),
and I think I kinda like it.

It seems clean and there's no "magic", so there are no corner cases that
I can see.

The number of ""s may be an impediment against using it in some cases,
though.  If you look at a simple format statement today:

(message "The time is %d in the %s bit of %s" clock part country)

I don't think you'd want to rewrite that to

(message "The time is %d%" clock " in the %s%" part " bit of %s%" country)

Or would you?  (The final "%" is optional, of course.")  It has the
advantage that you don't have to count to match up variables with
formatting statements, but it's not as immediately clear what the
resulting string will end up looking like.

Hm...  

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