emacs-devel
[Top][All Lists]
Advanced

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

Re: RFC: String interpolation


From: Ted Zlatanov
Subject: Re: RFC: String interpolation
Date: Mon, 12 Dec 2016 14:51:09 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

On Mon, 12 Dec 2016 09:46:05 -0800 Paul Eggert <address@hidden> wrote: 

PE> Why not just extend "format" so that it allows trailing "...%" in the format
PE> string to mean "argument value spliced here"? After the argument you can
PE> continue on with the format, which must start with the rest of the 
conversion
PE> specification. E.g.:

PE>   (format "Altitude= %" alt ".2f, direction = %" dir ".2f.")

PE> might output "Altitude = 300.57, direction = 240.93."

I like how this separates expressions from strings. It might be more
readable if the % begins the next string:

    (format "Altitude= " alt "%.2f, direction = " dir "%.2f.")

It has some downsides: it only works in one function; `(apply 'format ...)`
can become surprising; and repeating a parameter requires duplicating
the code.

Ted




reply via email to

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