Clément Pit-Claudel <
address@hidden> schrieb am So., 2. Juli 2017 um 18:34 Uhr:
On 2017-07-02 11:03, Noam Postavsky 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 extend functions all the time. Here's a random entry from NEWS:
*** Time conversion functions now accept an optional ZONE argument
that specifies the time zone rules for conversion. ZONE is omitted or
nil for Emacs local time, t for Universal Time, 'wall' for system wall
clock time, or a string as in the TZ environment variable. The
affected functions are 'current-time-string', 'current-time-zone',
'decode-time', and 'format-time-string'. The function 'encode-time',
which already accepted a simple time zone rule argument, has been
extended to accept all the new forms.
There's no difference between those changes and this one: the new syntax was an error before, but now has a specified meaning.
Also, the syntax is very heavy. Was it inspired by another programming language? The ones I'm familiar with use $1, {1}, or similar syntax, but I've never seen %1$s :/
As said, it comes from GNU printf.
We need to use a syntax that's backwards-compatible, that rules out $1 or {1}.