[std-interval] More on interval computations as proofs
Gabriel Dos Reis
gdr at integrable-solutions.net
Sat Sep 30 21:06:00 PDT 2006
Sylvain Pion <Sylvain.Pion at sophia.inria.fr> writes:
| Gabriel Dos Reis a écrit :
| > Sylvain Pion <Sylvain.Pion at sophia.inria.fr> writes:
| > | An alternative implementation is to have a global flag like errno,
| > I would not support that. Global variables pose significant
| > problems,
| > both for users and implementers -- these days errno really is a
| > function. Specially in multi-threaded environment (C++ is seriously
| > considering concurency).
| Actually, I mentioned errno on purpose because it is thread-safe.
because implementers have taken extra step to make it so. Furthermore,
even when each thread has been made to use its own view of errno, it
still fails the composition test: Think of
c = f(h() + i(), y());
Neither, the C, neither the C++ standards say it is thread safe.
Essentially, one needs thread-local storage -- which none of the
standard proposes. You could make the argument that the standard
library does not need to be written in standard C++, but that would
start pushing the limit. I would suggest not to explore the errno route.
errno is supported only for historical reason. If it were to be done
again with hindsight, I suspect it would be done differently.
| Now, for users, what would be more comfortable ?
As a user, I would definitely not to have to deal with errno. It is a
back hole. Its proper use requires tests at every stages, i.e. a
maintenance nightmarre. Part of the reasons why we got exceptions in
the first place.
| (side note : actually, if we had concepts with contexts, I think
| the problem would be solved nicely,
| but it's not part
| of the current concept proposals :(
| > Another alternative design could throw an exception.
| I fear it might be too costly. Throwing an exception with GCC costs
| 20,000 cycles (Sun does better, although my measurements date back
| from several years).
yes, it would be interesting to have recent data. Also, as you said,
you would essentially have two versions -- one "safe", throwing;
another one potentially "unsafe", non-checking non-throwing.
More information about the Std-interval