On Mon, 2009-09-28 at 23:16 +0100, David Rush wrote:
> 2009/9/28 Alaric Snell-Pym <[email protected]>:
> > On 28 Sep 2009, at 5:31 pm, John Cowan wrote:

> >> and it should not be a requirement that Scheme implementations signal
> >> an error on fixnum overflow -- returning an inexact result should
> >> still be fine.
> 
> That gives me the screaming heebie-jeebies. It really does.

I think we have to look at dire failure conditions.  And really, we 
have to make a choice between some horrible ones here.

With bignums limited by the size of machine memory, the dire failure 
condition (particularly easy to hit with rationals) is that the
execution of your program consumes all memory and aborts or crashes.
The pernicious part is that the system may not even have room to 
open a debugger to handle the abort.

With fixnums limited by the size of the machine words and no error 
reporting a la Stalin, the dire failure condition is that you are
getting your answer but have hit an unknown number of modulus 
operations at unknown steps of the intervening computation and thus 
the answer you get may bear no relation to reality, and you have 
no warning of this fact at all.  This is the scenario that gives 
me the worst heebie-jeebies.

With fixnums limited by the size of the machine word and error 
reporting, the dire failure condition is that ythe execution of 
your program halts -- but at least it does so before consuming 
all memory and without giving you a wrong answer, and you can open
a debugger without dumping the aborted image out of memory.

With overflow to an inexact number, the first failure condition is 
that you get your answer but it may be off by one part per million
or so, which is not so dire.  

But at the same moment, your program has lost the ability to use 
it in further operations requiring exact integers, such as using 
its modulus as a vector index, etc, and this may result in a dire
failure later -- usually an execution abort when the program 
attempts something it just isn't allowed to do with inexact 
numbers. 

None of these options are pretty.  I think "consume all memory and
crash" is the worst of them, so I don't want to wind up using 
bignums (particularly big ratios) accidentally.  I definitely 
want the ability to request a signal if I exceed fixnum bounds in
my integer calculations, especially including the numerators and
denominators of ratios.

Don't get me wrong; I think bignums are valuable, and should definitely
be available to use with due caution; but I don't want to ever get 
into bignums by accident, because that happens just seconds before 
the worst kind of crash.

                                Bear



_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss

Reply via email to