Proposal: fixing the 'pure' floating point problem.

Walter Bright newshound1 at digitalmars.com
Sun Mar 15 13:50:07 PDT 2009


Don wrote:
> A has called a function in B. B is not a floatingpoint module, so b() 
> can only be called when the mode is set back to the default. a() 
> violates this contract, so a() is incorrect. There's nothing wrong with 
> b() or c(). If a() wants to call b(), it needs to restore the mode 
> first; or else change b() into another floatingpoint module.

Ok, this was the missing piece in my understanding of the proposal.

But this requires that std.math either be floatingpoint, or two versions 
of it must exist if you want to do change the rounding modes on it.

> Something interesting about my proposal is that although it is motivated 
> by the purity problem, that's simply a rule for the compiler -- the 
> rules for programmers do not involve purity at all.(See my other post). 
> Do not call _any_ functions in non-floatingpoint modules (pure or not) 
> without restoring the rounding modes back to the default.

They could be done in terms of pure - if you call any pure function, the 
modes must be set to the default.



More information about the Digitalmars-d mailing list