On Apr 20, 2014, at 6:20 PM, John Cowan <[email protected]> wrote:

> I'm putting these questions for discussion [...]


A fascinating set of questions; I have several observations.  I hope people 
will forgive me if I use an obsolete R5 term by mistake, Wraith Scheme -- my 
implementation -- stopped there ...

First, regarding questions (3) and (4), I suggest that John's posting 
inadvertently and unnecessarily conflates fixnum/flonum with exact/inexact.  
Thus it is certainly possible to imagine a complex number whose real and 
imaginary parts are both inexact and both happen to be stored as fixnums, and 
it is also possible to imagine a complex number whose real and imaginary parts 
are both exact and both happen to be stored as flonums.  (E.g., a user could 
type (make-rectangular #i2 #i3) or (make-rectangular #e2.1 #e4.7). Users do the 
strangest things ...)  I conjecture that John meant to ask whether the domain 
of the real and imaginary parts of complex numbers should be restricted to 
numbers that can be stored as integers in the range, say of 24-bit signed ints.

Second, and similarly, regarding questions (2) and (1), there is no conceptual 
reason to eschew inexact rationals or inexact integers.  A user can always 
construct inexact integers, and may divide two of them.  Read again about how 
users do the strangest things ...

Third, regarding question (1), there is a substantial can of worms opened when 
you have bignums available and are worried about exactness or precision.  For 
example, suppose you have two numbers x and y which happen to be stored as 
flonums, and whose absolute values are so large that if you multiply them the 
result will overflow the range of your kind of flonum.  Then there are at least 
a couple of choices for what (* x y) should do, namely

    (A) Return an inf.

    (B) Coerce both x and y to bignums and return their bignum product.  Note 
that if you have sufficiently large bignums as to run out of memory, you may 
have to return an inf anyway.

In regard to (B), I shouldn't have to say, but I will say anyway, that any 
flonum of sufficiently large absolute value necessarily represents an integer 
-- if the exponent shifts the binary point past the right end of the 
significand, integer it must be, though those who want to argue may challenge 
this point if the sticky bit is set.

This point is particularly telling if both x and y are specified as exact, for 
in that case we have two exact ints (albeit stored as flonums), and a system 
that is perfectly capable of multiplying them and returning an exact result.  
Shouldn't we do that?  And even if they are not exact, doesn't such a coercion 
do the right thing in terms of preserving as much information about the result 
of the multiplication as possible?

At this point, I suspect that any Schemers who use the language for scientific 
or engineering calculations will be jumping up and down, waving their arms, and 
saying "NO!!  NO!!  NO!!", if only because of the probable slowness of 
repeatedly multiplying bignums of, say, a few thousand digits each.  And if I 
were so foolish as to suggest having a mode bit to select whether bignum 
coercion was forced or forbidden, I myself might not survive the experience -- 
a few of you know where I live.

A possibly useful rule might be that a calculation may return a bignum result 
only if at least one of its inputs is a bignum, but I am not trying to force 
the discussion, only to make a suggestion.  And I might have kept my mouth shut 
if I hadn't moved recently.

I look forward to the discussion of this matter.

Jay Reynolds Freeman
-------------------------------
[email protected]
http://JayReynoldsFreeman.com (personal web site)


_______________________________________________
Scheme-reports mailing list
[email protected]
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports

Reply via email to