[Top][All Lists]

[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 19:33:25 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Paul Eggert <address@hidden> writes:

> Why not just extend "format" so that it allows trailing "...%" in the
> format string to mean "argument value spliced here"? After the
> argument you can continue on with the format, which must start with
> the rest of the conversion specification. E.g.:
>   (format "Altitude= %" alt ".2f, direction = %" dir ".2f.")
> might output "Altitude = 300.57, direction = 240.93."
> That way, you can easily replace the expressions without giving them names:
>   (format "Altitude= %" (+ alt 100) ".2f, direction = %" (- dir) ".2f.")

Hm, that's a solution I don't think I've seen in any other languages?  I
think this looks kinda attractive...

The readability is somewhat hindered by all the quote marks, but if you
format it differently

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

it's perhaps clearer.  But the "%" on one line and the ".2f" on the next
is perhaps not optimal?  Hm...  What about something like...  er...

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

Does that look clearer?

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