[Top][All Lists]

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

Re: (format "Hello %1$S%2$s" 'world "!")

From: Noam Postavsky
Subject: Re: (format "Hello %1$S%2$s" 'world "!")
Date: Sun, 2 Jul 2017 12:54:59 -0400

On Sun, Jul 2, 2017 at 12:32 PM, Clément Pit-Claudel
<address@hidden> wrote:
>> Why would we need a new function since %n$ would be an error for the old 
>> format anyway?
> This in itself is a good reason to have a new function.  A new function lets 
> you migrate existing code, including plugins, to the new syntax, and load the 
> polyfill in older Emacsen.  A new syntax that causes errors in old Emacsen 
> isn't usable by anyone outside of Emacs core, for fear of compatibility 
> problems.

We can still give a new name I suppose.

> The ones I'm familiar with use $1, {1}, or similar syntax,

What's the equivalent of %1$d in that syntax? Or is it just strings?

> but I've never seen %1$s :/

It's a POSIX extension to C's printf [1,2], also used by Java [3] and perl [4].

[1]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html
[2]: https://en.wikipedia.org/wiki/Printf_format_string
[3]: https://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html
[4]: https://perldoc.perl.org/functions/sprintf.html

reply via email to

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