Low-level math op behavior
Okay, since we're finally talking defined math semantics, lets talk the low-level ops. All our math ops right now just quietly do their thing. If values wrap, truncate, or otherwise fuzz out, we don't do anything special. This is fine, and fast, and what many languages want. It is, however, reasonable to have math ops that are a bit higher-level -- basically throwing exceptions if something exceptional happened rather than quietly proceeding. What I'm thinking is that we add an O or X (or E, I don't care. I suppose we could get more verbose there too) variant to the basic math ops which checks the result for validity and throws an exception on something exceptional happening. Only for the basics (add, subtract, multiply, divide, possibly modulus) but it ought to be useful. Folks think it's worth it? -- Dan --it's like this--- Dan Sugalski even samurai [EMAIL PROTECTED] have teddy bears and even teddy bears get drunk
Re: Low-level math op behavior
At 11:29 -0400 8/24/04, Dan Sugalski wrote: What I'm thinking is that we add an O or X (or E, I don't care. I suppose we could get more verbose there too) variant to the basic math ops which checks the result for validity and throws an exception on something exceptional happening. For floating point operations, and that's pretty much all perl 5 seems to do, the not a number or NaN capability of the floating point arithmetic units is pretty good. Correctly ignored, an error condition can resolve itself in a later formula. An underflow, for instance, when added to a legitimate floating point number is not an error. It's just a no-op. Even a divide by zero error can be a non-event. Things like real square roots of negative numbers are different. Perl6 could define some of its own NaN's if it seems appropriate. Perhaps a NaN meaning undef. A simple way to identify and categorize a NaN might be nice. -- -- On the eighth day, about 6 kiloyears ago, the Lord realized that free will would make man ask what existed before the Creation. So He installed a few gigayears of history complete with a big bang and a fossilized record of evolution. --
RE: Low-level math op behavior
So, would it have things like $i = $j /E $k $i = $j %E $k which would both throw and exception if $k == 0 whereas $i = $j / $k $i = $j % %k would not throw an exception and would instead return NaN -Original Message- From: Dan Sugalski [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 24, 2004 11:29 AM To: [EMAIL PROTECTED] Subject: Low-level math op behavior Okay, since we're finally talking defined math semantics, lets talk the low-level ops. All our math ops right now just quietly do their thing. If values wrap, truncate, or otherwise fuzz out, we don't do anything special. This is fine, and fast, and what many languages want. It is, however, reasonable to have math ops that are a bit higher-level -- basically throwing exceptions if something exceptional happened rather than quietly proceeding. What I'm thinking is that we add an O or X (or E, I don't care. I suppose we could get more verbose there too) variant to the basic math ops which checks the result for validity and throws an exception on something exceptional happening. Only for the basics (add, subtract, multiply, divide, possibly modulus) but it ought to be useful. Folks think it's worth it? -- Dan --it's like this--- Dan Sugalski even samurai [EMAIL PROTECTED] have teddy bears and even teddy bears get drunk The information contained in this e-mail message is privileged and/or confidential and is intended only for the use of the individual or entity named above. If the reader of this message is not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify us by telephone (330-668-5000), and destroy the original message. Thank you.
RE: Low-level math op behavior
At 11:34 AM -0400 8/24/04, Butler, Gerald wrote: So, would it have things like $i = $j /E $k $i = $j %E $k which would both throw and exception if $k == 0 whereas $i = $j / $k $i = $j % %k would not throw an exception and would instead return NaN That'd be the plan, yeah. $i wouldn't get NaN if $i is an integer, though I expect everyone figured that one out. :) -Original Message- From: Dan Sugalski [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 24, 2004 11:29 AM To: [EMAIL PROTECTED] Subject: Low-level math op behavior Okay, since we're finally talking defined math semantics, lets talk the low-level ops. All our math ops right now just quietly do their thing. If values wrap, truncate, or otherwise fuzz out, we don't do anything special. This is fine, and fast, and what many languages want. It is, however, reasonable to have math ops that are a bit higher-level -- basically throwing exceptions if something exceptional happened rather than quietly proceeding. What I'm thinking is that we add an O or X (or E, I don't care. I suppose we could get more verbose there too) variant to the basic math ops which checks the result for validity and throws an exception on something exceptional happening. Only for the basics (add, subtract, multiply, divide, possibly modulus) but it ought to be useful. Folks think it's worth it? -- Dan --it's like this--- Dan Sugalski even samurai [EMAIL PROTECTED] have teddy bears and even teddy bears get drunk