Floating point rounding modes: we should restrict them slightly

Rainer Deyke rainerd at eldwood.com
Tue Sep 15 14:16:45 PDT 2009


Don wrote:
> The thing you missed is that the non-memoisable pure functions can only
> read the global state.

No, I saw that.  But if a (pure) function calls another (pure) function
that depends on global state, then the first (pure) function also
depends on global state.

int global_state;

pure int f() {
  return global_state;
}

pure int g() {
  return f();
}

int h() {
  global_state = 5;
  return g();
}

> But you ALWAYS have a choice about that. You can rewrite functions which
> are independent of locale, or you can pass the locale as a parameter.
> With floating point, you don't have that option.

True.  Unless you add functions/operators that use a fixed rounding mode
to the language.

> BTW, global locales suck, big time. The idea that you can specify the
> formatting in the form of a locale is clearly the creation of someone
> who had never worked in an international environment. (And any locale
> which includes 'currency' is clearly the creation of an idiot).

No argument there.


-- 
Rainer Deyke - rainerd at eldwood.com



More information about the Digitalmars-d mailing list