emacs-devel
[Top][All Lists]
Advanced

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

Re: RFC: String interpolation


From: Stefan Monnier
Subject: Re: RFC: String interpolation
Date: Thu, 08 Dec 2016 16:31:50 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

> Neat, it looks like they do almost exactly the same, right? Except % vs. $.

Pretty much, yes.

> 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.

Indeed.  But the Elisp interpreter is slow compared to the `format`
parser, so I'd expect the use of a single `format` call to be more
efficient (both in code size and execution time).  That's just a gut
feeling, tho, I have no hard data to back it up (my implementation uses
a single `format` call partly because of that gut feeling but also
because it seemed easier).

> You could even imagine getting rid of format entirely, and parsing
> even the format sequences at compile time.

My gut says that the resulting Elisp code would probably be even larger
and slower.

> 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.

I added supported for {..} not so much because of slashes and such, but
simply to resolve the ambiguity between "%{a}b" and "%{ab}".


        Stefan




reply via email to

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