Proposal: fixing the 'pure' floating point problem.

Michel Fortin michel.fortin at michelf.com
Sat Mar 14 04:09:36 PDT 2009


On 2009-03-14 02:45:27 -0400, Walter Bright <newshound1 at digitalmars.com> said:

> Don wrote:
>> That's true, but if you're in a floatingpoint module, and you call a 
>> non-floatingpoint module, it's your responsibility to make sure that 
>> the rounding mode is back to normal. You're saying that you don't care 
>> about the status flags. So it's your own fault if you get surprising 
>> results.
>> 
>> The primary use for adjusting the rounding mode is for things like 
>> implementing interval arithmetic. Thus, it's only ever used for small 
>> functions.
> 
> Perhaps we can go with something simpler. If you call a pure function, 
> then the modes must be set to their defaults.

Just dumping another idea in the suggestion box. Perhpas for all 
functions the compiler could store the floating point flags it expects 
when called. All functions would expect the default flags, but there 
could be a way to attach different flags to a function. Then, the 
compiler makes sure that when calling that function the flags are set 
properly.

The net result is that if you keep the default on every function, 
you'll get the exact same assembler result as today. If you set the 
flags on a function, then the caller will set the flags to that before 
calling, but it's only necessary if they're different from the flags in 
the current function.

And perhaps there should be a way to specify a function that can accept 
any flag configuration. In that case, memoizing that function would 
require considering the floating point flags as an extra parameter.

Now, tell me, am I using a missile to kill a fly?

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list