[racket] ~r behavior with respect to the sign

From: Dmitry Pavlov (dpavlov at ipa.nw.ru)
Date: Tue Jan 14 16:07:23 EST 2014

Ryan,

> If you (or anyone else) would like to add more padding options that acts
> like the combination of ~a and ~r above, that would be fine with me. I don't
> have time to work on the code right now, but I'll take patches or pull
> requests.

OK, but I am a bit uncertain about how such a patch should
handle the #:min-width parameter. See, ~r now gives
longer strings for negative numbers, #:min-widths being equal.

> (~r (- pi) #:precision '(= 2) #:min-width 5)
"- 3.14"
>  (~r pi  #:precision '(= 2) #:min-width 5)
" 3.14"

Is that intentional too? With the sign attached to the number,
such behavior will be
- unnatural, because characters to the left and to the right
from the sign account for #:min-width, while the sign itself
does not
- much surprising to C and Fortran users

What do you think will be a good interface here?
You can suggest an extension of interface to ~r
and I will try and spend a couple of hours writing a patch.

Best regards,

Dmitry

Posted on the users mailing list.