On Sep 23, 2009, at 4:23 PM, John Cowan wrote:

> Brian Mastenbrook scripsit:
>
>> Once again, I'm not understanding why bignums are so difficult that
>> they can't be expected from an implementation.
>
> It's not about difficulty, it's about expectations.  R5RS says that a
> procedure which is trying to report an exact integer too large for the
> implementation may silently report an inexact result or throw an  
> error, at
> its option.

Yes, I'm aware of what the R5RS says, but in practice I think it might  
as well have been a requirement since few implementations purport to  
implement the R5RS but do not provide bignums.

> Some people *want* Schemes in which all numerical operations
> run in essentially constant time.  That leads to either a fixnum/ 
> flonum
> system (#2 below) or a fixnum/flonum/compnum system (#3 below).

Using flonum arithmetic only would provide the same results for these  
users.

> 2)      -bignums +inexact -complex:  This is a Scheme where all  
> numbers
>        are real and all arithmetic happens in essentially constant  
> time.
>        Most non-Lisp languages look like this.  Again, ratios without
>        bignums make little sense.

I'd love to know how you're measuring "most" :-)

One important difference between C & co and Scheme is that C integers  
do not overflow to inexact numbers on any basic arithmetic operation.  
For the unsigned types, the behavior is explicitly modular, which is a  
different animal yet.

On a tangential note, experience also suggests that 32-bit integers  
are insufficient even on 32-bit hardware; most implementations of C  
provide a 64-bit integer type for this reason, and it's commonly used  
in library APIs for types like size_t.

> 5)      +bignums +ratios -inexact -complex: Exact numbers only.
>        Reasonable for some purposes, but will often be slow without
>        inexact support, so unsuitable for numerical work.

If "numerical" implies "floating point", sure. It's quite possible to  
do many useful numeric computations in such a Scheme, however,  
including the number-theoretic operations used in many cryptographic  
systems.

For what it's worth, I'd be perfectly happy at this level. To butcher  
Kronecker, God made the exact numbers; all else is the work of humans.

> 7)      +bignums -ratios +inexact -complex: A good all-round  
> compromise,
>        providing exact integers and inexact real numbers.  ISLisp  
> looks
>        like this.  Many people like this design.

This is a good compromise, given that unlimited-precision ratios can  
cause surprising representation bloat in some circumstances.

>> [N]ot providing bignums seems to be a relatively rare choice among
>> implementations that purport to implement the R5RS without  
>> restriction
>> or limitation.
>
> Part of the reason for small Scheme is to allow such implementations  
> to
> come out into the light, to claim conformance even though they are  
> lacking
> quite a lot of IEEE/R4RS/R5RS.

Should we do the same for implementations without unlimited-extent  
reifiable continuations, proper tail calls, hygienic macros (or with  
broken hygiene), etc.?

--
Brian Mastenbrook
[email protected]
http://brian.mastenbrook.net/

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

Reply via email to