[Top][All Lists]

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

bug#32252: [PATCH] %o and %x now format signed numbers

From: Paul Eggert
Subject: bug#32252: [PATCH] %o and %x now format signed numbers
Date: Tue, 24 Jul 2018 07:22:52 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

Helmut Eller wrote:
With your change %x will also have quite a different meaning in C11.

Not really, as Emacs (format "%x" N) agrees with C11 printf ("%x", N) in all values of N that are valid in both languages. In C11, negative values are not valid, as printf ("%x", N) has undefined behavior when N is negative. So we are discussing an area where Emacs Lisp can define behavior without introducing incompatibilities with C11.

If we changed (format "%x" -1) to signal an error instead, that would also be upward-compatible with C11. However, it's more useful for something like (format "#x%x" -1) to output a string that can 'read' can scan to get -1, something that's not true of Emacs now.

This seems like overkill for such a small
change to functionality that hardly ever matters; plus, %x, %X and %o
would continue to have problematic machine-dependent semantics and
would not be sensibly extensible to bignums.

If it doesn't matter to you then why make the change/break at all?

It does matter to me, actually. I think Emacs should have sensible behavior even in corner cases that hardly ever arise in real programs.

reply via email to

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