FORMAT prefix parameter '#' not handled properly
Per Bothner
per@bothner.com
Sat Oct 8 00:24:00 GMT 2011
On 10/07/2011 05:05 PM, Charles Turner wrote:
> The following patch fixes this problem, and produces no regressions.
>
> The only slightly odd behaviour is that
>
> (format #t "~#f" java.lang.Math:PI)
> => 3.
>
> SBCL returns 3.141592653589793. I'll look at the spec tomorrow to see
> what the final word is on this, but Kawa stuffs the argument length into
> the "decimals" field of LispRealFormat when it encounters a '$' and into
> the "width" field when it encounters an 'f'.
This is as required by the CL HyperSpec.
> So the discrepancy is easy
> to identify, I'm just not sure what to do about that right now.
The issue is not the '#', but the narrow field width. You get the same
discrepancy with "~1f". Kawa and sbcl do the same in the case of "~2f".
The reason for the difference is because different interpretations of thise:
If it is impossible to print the value in the required format in a
field of width w,
then one of two actions is taken. If the parameter overflowchar is
supplied, then
w copies of that parameter are printed instead of the scaled value of
arg.
If the overflowchar parameter is omitted, then the scaled value is
printed using more
than w characters, as many more as may be needed.
I.e. different meanings of "then the scaled value is printed using more
than w characters, as many more as may be needed". I think the Kawa
behavior
is reasonable and within the spec, but you might try to experiment with more
edge cases.
--
--Per Bothner
per@bothner.com http://per.bothner.com/
More information about the Kawa
mailing list