The idea of a SRFI for easy formatting of numbers
are good.
Comments
--------
- the name OBJECT->STRING is more "Schemy"
(it's pretty long though)
- I find the name of the parameter DEPTH in the documentation
confusing. (It makes me think in two dimensional output)
- An way to get a hard limit on the width of numbers would be
convenient.
> (fmt -1.3333 5 4 'hard-width)
"-1.33"
- The
[[<width>] [<depth>] [<char>] [<radix>] [<plus>] [<exactness>]]
should probably be
[<width>] [[<depth>] [[<char>] [[<radix>] [[<plus>]
[<exactness>]]]]]]
- I think the exactness parameter is underspecified.
E.g. what happens if I use 'e with an inexact number?
- I find the specification of the (FMT <others>) a little too short
BUGS
----
1. There appears to be a problem in the case
where a negative number is truncated:
> (fmt -1.55555 3 2)
"-1.54"
My TI-83 writes "-1.56".
2.
I don't understand this behaviour:
> (fmt -5.0 0 #\space 10 + 'e)
. fmt: exact number cannot have a decimal point 10 depth
> (fmt -5 0 #\space 10 + 'e)
. fmt: exact number cannot have a decimal point 10 depth
3.
; DrScheme prints exact rationals as p/q
> (fmt 1/2 0 #\space 10 +)
"+1/2.0000000000"
> (fmt 1/2)
"1/2"
> (fmt 1/2 5)
" 1/2"
> (fmt 1/2 5 0)
; The period should be there when depth is 0
" 1/2."
> (fmt 1/2 5 2)
"1/2.00"
; my fault forgot #\space, but strange error
> (fmt 1/2 5 2 10)
. fmt: bad argument (10) (null? (10))
; An error saying that radix should be 'b 'd 'o or 'x would
; be more helpful
> (fmt 1/2 5 2 #\space 10)
. fmt: bad argument (10) (null? (10))
--
Jens Axel Søgaard