[r6rs-discuss] Proposed features for small Scheme, part 9: modules

John Cowan cowan at ccil.org
Mon Oct 12 15:43:59 EDT 2009


Brian Harvey scripsit:

> As a programmer, I'd rather be able to say
> 
> 	(if (defined? numerator) ...)
> 
> than drag in a special symbol %rational.

%rational (remember the % is metalanguage, not part of the identifier)
was a thinko for %ratios.  Numerator and denominator are still defined
even if you don't have %ratios (in which case numerator is the identity
function and denominator always answers 1).

> And the recent discussion of
> bignums suggests to me that "has bignums" is not a yes-or-no question;
> I really want to be able to say
> 
> 	(if (exact? (string->number "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") ...)
> 
> or whatever range I actually need.

Well, that's the thing.  +%bignums (metalanguage for "the 'bignums'
feature group is present) means that exact integer overflow is an error,
whereas -%bignums means exact integers overflow into inexact results.
So you have to conditionalize to know whether your code will even work,
since it may throw an error instead.

Similarly, +%ratios means you get an exact rational result from / where
the quotient is not an integer, whereas -%ratios means you again get an
inexact result.


-- 
Samuel Johnson on playing the violin:           John Cowan
"Difficult do you call it, Sir?                 cowan at ccil.org
 I wish it were impossible."                    http://www.ccil.org/~cowan



More information about the r6rs-discuss mailing list