simon-git: spigot (master): Simon Tatham
Commits to Tartarus hosted VCS
tartarus-commits at lists.tartarus.org
Thu Mar 22 20:11:20 GMT 2018
TL;DR:
c218518 New type 'bigint_or_inf' for interval upper bounds.
d8e897b baseout.cpp: fill in some uninitialised structure fields.
Repository: https://git.tartarus.org/simon/spigot.git
On the web: https://git.tartarus.org/?p=simon/spigot.git
Branch updated: master
Committer: Simon Tatham <anakin at pobox.com>
Date: 2018-03-22 20:11:20
commit c2185183c7afda4bbdd6e3ad73d26c3a921bc514
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=c2185183c7afda4bbdd6e3ad73d26c3a921bc514;hp=0b376041a4687bd3f9a2a4142b9a8b2f743d9b9f
Author: Simon Tatham <anakin at pobox.com>
Date: Thu Mar 22 19:02:27 2018 +0000
New type 'bigint_or_inf' for interval upper bounds.
When I had my spree of fixing gen_interval() functions the other day,
I got uncomfortable about the convention of returning *high = 0 to
indicate that the upper bound of the starting interval is actually
+infinity. Partly that was just on general principles of semantic
sanity (zero already has a meaning!); partly it's because I was
reminded that some starting intervals have negative lower bounds (so
it actually wouldn't be totally unreasonable to want an interval to
_really_ be [-n,0]); and mostly it's because it just seems like an
error-prone way of doing things, because you have to ensure that
you've checked for the special-case value everywhere you use an
interval upper bound and no compile-time check will help you avoid
missing one.
So now interval upper bounds have a new type 'bigint_or_inf', which is
a trivial wrapper class which can represent any bigint but also has an
explicit representation for infinity. There's an automatic type
conversion from bigint, but not back to it: extracting the integer
value is done by calling the finite() method, which reminds you to
also add a handler in case it returns false. Hence, I can't forget the
infinite case any more without a compile error.
This comes at the cost of a load of extra boilerplate in the wrapper
class, of course, but on the other hand, Core1 and Core2 look
noticeably nicer now they don't have to carry around their own
separate bool alongside lots of their interval-bounding bigints.
algebraic.cpp | 4 +--
arithmetic.cpp | 28 +++++++--------
consts.cpp | 18 +++++-----
erf.cpp | 4 +--
exp.cpp | 8 ++---
expint.cpp | 10 +++---
gamma.cpp | 16 ++++-----
hypergeom.cpp | 18 ++++++----
misc.cpp | 9 +++++
monotone.cpp | 4 +--
python-module/internal.cpp | 4 +--
spigot.cpp | 88 ++++++++++++++++++++++++++++++----------------
spigot.h | 35 ++++++++++++++----
sqrt.cpp | 8 ++---
trig.cpp | 14 ++++----
trigint.cpp | 4 +--
unary.cpp | 4 +--
17 files changed, 167 insertions(+), 109 deletions(-)
commit d8e897b639ceb079453cdf059d1d4d2e641ab0d7
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=d8e897b639ceb079453cdf059d1d4d2e641ab0d7;hp=c2185183c7afda4bbdd6e3ad73d26c3a921bc514
Author: Simon Tatham <anakin at pobox.com>
Date: Thu Mar 22 19:35:30 2018 +0000
baseout.cpp: fill in some uninitialised structure fields.
I just remembered I'd written 'test.sh --valgrind' a while back, and
tried it out to see if it still got a clean sweep. It didn't. Now it
does again.
(Sadly, spigot under valgrind is _way_ too slow to run as part of my
automatic build-time testing...)
baseout.cpp | 2 ++
1 file changed, 2 insertions(+)
More information about the tartarus-commits
mailing list