
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 03/28/2010 10:13 PM, Scott McMurray wrote:
Blockable exceptions are an XInt library thing, which I added because people are asking for them. See the XInt documentation, the page labeled "Exceptions and Exception Blocking" (ref_exceptions.html).
Then the obvious question is, "Why isn't overflow blockable"?
And it's an excellent question. The only justification for making it non-blockable is that, if it were blockable, then nearly every function in the library could potentially return a Not-a-Number value, and you'd have to check for it constantly when blocking exceptions. That would defeat the intended purpose of the exception-blocking mechanism (see below). As it's not, you only have to check for the Not-a-Number value on the few functions that can throw a blockable exception.
If the point is to be useful when exceptions are off, they should all be able to generate special values instead of throwing.
There's no other logical response if there's no cryptographically-secure random number generator, and the user asks the library to instantiate one. (That's not in the version that was uploaded to the Boost Vault yet.) And it's debatable whether there's any other consistent and mathematically logical way to handle passing Not-a-Number values to functions that return anything but xint::integers. The mechanism isn't there so that the exception-hating crowd can get away with avoiding exception-handling. It's there to give the developer using the library the flexibility to treat its functions as returning error codes, rather than throwing exceptions, when it would make for more readable code. - -- Chad Nelson Oak Circle Software, Inc. * * * -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkuwJPcACgkQp9x9jeZ9/wTmDQCff6ggBH/+qmL+hQ/Gll3mhaTc JCEAoPs003wuenRQbe3zjgmicmc0QdEW =8uDr -----END PGP SIGNATURE-----