Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I'm sorry, but Perl also silently discards information [perl.org]. (Yes, I know that .9repeating is equal to 1, but perl's implementation only stores an imperfect representation of that).

    The problem is that processors are designed to do approximate math quickly, so most computer math ends up being approximate. Perl just happens to be using a closer approximation to what you expect, in this case.

    Personally, I would prefer that Perl's DWIM resulted in preserving all information available, like (IIRC) Haskell does (of course, this is still limited by memory availability). Yes, this would be slower. But Perl usually is designed to be correct first and fast second.

    Obviously, it's too late to do this with Perl 5 because of backward compatability concerns, and I'm not sure if this behavior is desirable in Perl 6.

    • One thing to remember is that many compilers and operating systems may help you down to road to discard this information. Perl compiled Intel C++ on Linux, for example, failed several floating point tests in Perl. By removing optimizations (that is, making the compiler generate code to do the math correctly), the tests were made to pass. Various operating systems and compilers occasionally include "fast" math libraries as well that do a similarly good job of providing optimized approximations. I would s

      • This is a good point. I think the central problem here is that you have to be careful what guarantees you make. If a datatype is defined as a lower-level language's datatype, you can only assume the guarantees that the lower-level language makes. (And thanks to nonstandard compilers, sometimes not even those...)