Perl is worse!
Alex Martelli
alex at magenta.com
Fri Jul 28 08:03:36 EDT 2000
"Paul Boddie" <paulb at infercor.no> wrote in message
news:39814767.FFEFE5D0 at infercor.no...
[snip]
> > 1 + "foo" = string ("1foo")
>
> Doesn't Perl do this last one as well? I refer you to the example I give
above -
Nope; in Perl, 1 + "foo" is 1.
> to have such behaviour permeating one's code is "nasty" to say the least.
I do consider it impractical, but what's "nasty" about it?
> > 1 + 1j = complex
> >
> > So please don't tell me you don't want "automagic" type changing
when it
> > is already there and, I'd wager, you use it extensively.
>
> Actually, this kind of thing does irritate some people, but at least one
can
> claim that such behaviour for numbers is more or less accepted in wider
circles,
Specifically: in mathematics, there is a natural injection from naturals to
integers, from integers to rationals, from rationals to reals, from reals to
complex. Unfortunately, things are *NOT* all roses and wine in the
real world, because we don't really have rationals in Pythons (much less
reals, of course:-), but rather an approximation -- so, precision-loss,
which is a form of information-loss, threatens...:
>>> long(12345678901234567890123L*1.0)
12345678901234567741440L
While it takes the explicit 'long' converter to see it clearly, the
information
loss has really happened in the implicit and silent conversion of
long-integer
(unlimited-precision) to floating-point (limited-precision). Now *THAT*
is nasty!-) I guess not enough people use a lot of long-integers, so
they're
rarely bitten by this -- but I do a lot of combinatorics, where
long-integers
are a real blessing, thus, the IMPLICIT information-loss in long->float
conversion forces me to be *EXTREMELY* careful. Now if we had
unlimited-precision *rational* numbers, with both long-integers and floats
getting implicitly and silently promoted to suitable such *rationals*, the
world would be a very nice place again...:-).
> whereas 1 + "foo" is meaningless to almost everyone except Perl coders.
No way -- it's perfectly valid in C, too, except that there it means the
constant-string "oo". Really, truly, X my heart, I kid you not, check it
out if you don't believe me (I wouldn't blame you for disbelieving this!).
Alex
More information about the Python-list
mailing list