emacs-devel
[Top][All Lists]
Advanced

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

Re: RFC: String interpolation


From: Clément Pit--Claudel
Subject: Re: RFC: String interpolation
Date: Thu, 8 Dec 2016 14:31:22 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1


On 2016-12-08 14:05, Stefan Monnier wrote:
>>     (let ((a 12) (b 15))
>>       (fmt "$a + $b = $(+ a b)"))
> 
> Looks good.

Thanks :)

>>     (concat (fmt--print a) " + " (fmt--print b) " = " (fmt--print (+ a b) 
>> 'format "%.2f"))
> 
> I'm surprised, I'd have expected to expand to a call to (format ...).
> At least that's what my own take on it did (see below; incidentally it
> looks otherwise eerily similar to yours in syntax).

Neat, it looks like they do almost exactly the same, right? Except % vs. $.  
The nice part about not constructing a top-level call to format is that the 
full format string doesn't need to be reparsed every time.  You could even 
imagine getting rid of format entirely, and parsing even the format sequences 
at compile time.

> FWIW, I don't much like adding extra cases, so I'd stick to a minimal
> solution at least until we have enough experience with it to be sure
> which extra cases are worth the trouble.

Sounds reasonable.  I'm happy to drop the extended format codes with "|" in 
them.  Since ELisp variable names routinely include slashes and colons, I think 
having {} is useful (looks like your implementation supported that too?). Being 
able to specify a format string is nice too.

>> * Should this go into MELPA, ELPA, or core?
> 
> I think it might be worth thinking about it in the larger context of other
> special formatting we might have in strings.  I'm thinking here about
> things like docstrings and their \\[...] and stuff.  If we could
> imagine a path where those could end up merging, it would be great.

Indeed!

> (defmacro preformat (string)
...

This looks good too, thanks!

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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