Why not FP for Money?

Carlos Ribeiro carribeiro at gmail.com
Fri Sep 24 16:12:06 EDT 2004


On Fri, 24 Sep 2004 16:37:56 -0300, Batista, Facundo
<fbatista at unifon.com.ar> wrote:
> [Paul Rubin]
> 
> #- I really do think now that if we're serious about supporting
> #- decimals,
> #- we need decimal literals.
> 
> What do you mean with "decimal literals"?

If I got Paul right, it means the same I've been advocating: a
notation to write floating point decimals directly without the need to
pass strings or floats. We've proposed some alternatives:

1) 'd' suffix:  a = 10.123d
2) '$ prefix:  a = $10.123

Both alternatives are clean and easy to read, even for novices. The
'd' suffix is closer to what Python does already for longs (the 'L'
suffix). The dollar sign is easily recognized, even outside US, as a
money sign (it would be better for money/fixed point, really). The
changes to the parser are minimal, and there is *no* chance of any of
the proposed alternatives being of the 'that's already being used
class' -- no keywords are needed. It's just a matter of getting BDFL's
grace for this <wink>.

For now, I'm just playing with the alternatives -- it's pretty much
like the big decorator debate, only the timing is better :-)  (just
joking, really -- a good literal notation is *much* needed to allow
use of decimals without binary floating point surprises happening from
time to time).

-- 
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: carribeiro at gmail.com
mail: carribeiro at yahoo.com



More information about the Python-list mailing list