[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

forgive a stupid question, but ...



    Date: Mon, 30 Oct 89 17:30:45 est
    From: Hal Abelson <hal@zurich.ai.mit.edu>
    .. could someone remind me just why it is in my better interests for
    vector-ref and friends to signal an error when the index is an inexact
    integer, rather than just silently coercing it to exact?

Suppose you were porting a program from an Scheme that had arbitrarily
large exact integers to one that only had 32-bit exact integers.  Suppose
some intermediate result on the way towards computing a vector index
doesn't fit in 32 bits.  Suppose the 32-bit Scheme handles such overflows
by converting to inexacts (perhaps using floating-point).  Thus when you
arrive at the actual vector indexing operation, you've got an inexact
number.  If we "silently coercing it to exact" there is no guarantee that
you will get the same exact integer you would have gotten in the original
Scheme implementation (assuming you are even lucky enough to get an integer
and not some random rational).  If we "silently coercing it to exact" we
may silently introduce bugs.

You want that error to tell you that there was an unexpected excursion into
inexact arithmetic.  If you -expected- an inexact number, you would have
called INEXACT->EXACT.

[ I am now bracing myself for another month arguing about inexact numbers
  on this mailing list.  I anticipate spending two or three months a year
  for the rest of my life composing mail about this. ]