Perl6 RFC Librarian <[EMAIL PROTECTED]> writes, for Chaim Frenkel
<[EMAIL PROTECTED]>:
[...]
> =item As a floating point number
>
> The integer part would be the actual identifier. The fractional
> part could encode some classification scheme.
Floating point numbers don't work this way. Suppose I use a machine
with non-IEEE floats. Then some floating point numbers which are
exactly specifiable in IEEE fp might not be so on my machine, so I'll
get really weird error numbers. Does the comp.lang.perl.* hierarchy
really need, in addition to "BUG IN PERL: I added 0.1 to itself 10
times and didn't get 1.0" messages, some _justified_ posts about
difficulties with floating-point precision? Or does this mean I can't
build Perl on a machine without IEEE fp?
Note that this would also mean that many plausible schemes for dealing
with error codes (e.g. "I know it's an error of class 123 subclass 4,
so I'll just subtract 123.4 and multiply by 1e4 to get the remainder)
will require careful analysis of precision. Sounds like another one
of my CS sophistries? Try this:
<selena 107 [9:15] ~ >perl -de 42
Loading DB routines from perl5db.pl version 1.0402
Emacs support available.
Enter h or `h h' for help.
main::(-e:1): 42
DB<1> $err = 123.4567
DB<2> x $err-123
0.456699999999998
And we all know the next line of code will be
if (($err-123) =~ /^0.4567/) {
# DANGER! Reactor meltdown unless shut down
}
else { # Whew! That was close...
warn "non-fatal error encountered: $err\n";
}
Since you're anyway not using a _floating_ point, here are 2
alternatives:
1. Error codes are integers, but with an implied decimal point (fixed
point). E.g. 1234567 represents error 4567 in class 123.
2. Error codes as digit strings with decimal point. So "123.4567"
(_not_ 123.4567) represents error 4567. People will still try
stupid floating-point math tricks to get at the suberror code, but
at least we'll know they didn't read the bit in the documentation
where it will specifically warn _not_ to do this.
[...]
--
Ariel Scolnicov |"GCAAGAATTGAACTGTAG" | [EMAIL PROTECTED]
Compugen Ltd. |Tel: +972-2-6795059 (Jerusalem) \ We recycle all our Hz
72 Pinhas Rosen St. |Tel: +972-3-7658514 (Main office)`---------------------
Tel-Aviv 69512, ISRAEL |Fax: +972-3-7658555 http://3w.compugen.co.il/~ariels