Proposal: fixing the 'pure' floating point problem.

Don nospam at nospam.com
Sat Mar 14 10:22:55 PDT 2009


Michel Fortin wrote:
> 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?
> 
I think so. My proposal is basically like that, except that it asserts 
that (1) the state of the flags can be applied on a per-module basis; 
and (2) the only situations of practical importance are "default" and 
"other".
It's not just the rounding mode (which is an input), it's also the 
sticky flags, which are both an input and an output.



More information about the Digitalmars-d mailing list