I had a thought ... (I know, call the newspapers).

Alex Martelli aleaxit at yahoo.com
Thu May 31 11:21:23 EDT 2001


"Laura Creighton" <lac at cd.chalmers.se> wrote in message
news:mailman.991316267.13430.python-list at python.org...
> Lets give python a new type.  We will call it money.  And we will

Visual Basic has that.  It's called "Currency", I believe.

They even CLAIM "Even though it's larger, the Currency
data type is faster than the Single data type because
the Currency data type doesn't use the floating-point
processor" (quoted from "Microsoft Office 2000/Visual
Basic Programmer's Guide").  I think they're talking
though their hats.  The denotation character, if I recall
correctly, is @ in VB (@...?! I think that's because $
was already taken for strings), but $ in Visual FoxPro
(which also has Currency; type Currency is also in the
.NET minimal specifications -- any language must provide
it to interoperate fully in .NET).

I don't think anybody's really using it, though. I could
be wrong, it's hard to get precise statistics, but for
what I can judge from typical VB snippets seen around
they seem to be using the convenient notation (which, I
think, maps to floating-point) anyway.


> In 20 years I have had 0 luck teaching people to not use floating
> point for money.  The fools carefully ignored me and went back to

It appears to me MS isn't having much, even though they
did put Currency and Decimal and all into their hodge
podge of a language.  The fact that just writing a plain
simple 7.35 gives a float is apparently the killer.


> I am almost convinced that I can teach them to use the type money,
> a slower, more accurate type that accurately represents money and

What if it's FASTER too, as MS is these days claiming
for their Currency, see above?  I believe the claim is
unfounded, but that's another issue.  It still seems
to be little used even by the kind of people who take
any MS claim as gospel:-).

We can easily supply a Money or Currency or whatever
type today, *APART* from convenience of literals.  Maybe
for experimental purposes we can supply that with a
"preprocessor" at import time, ala PyHTML... (I'd use
$ though, much as I love the Euro -- requiring Unicode
source would not endear the concept to most users:-).


Alex






More information about the Python-list mailing list