[r6rs-discuss] What's under the hood?
brian at mastenbrook.net
Mon Sep 28 12:07:45 EDT 2009
On Sep 28, 2009, at 10:36 AM, John Cowan wrote:
> Brian Mastenbrook scripsit:
>> Which might be several, or none at all. In my opinion, the fixnum/
>> split is obsolete and should never be exposed to the user. Deliberate
>> points of underspecification are necessary for standards, but they
>> not be elevated into features.
> I basically agree, but I still think it's important to differentiate
> between Schemes that set a tight limit on the size of exact integers
> those that do not. That is the rationale of the %bignums feature
> (remember, the % is metalanguage). R5RS already has this distinction
> but doesn't formalize it.
> I also think it is important for the standard to prescribe a minimum
> for the largest exact integer on Schemes that have one. R5RS is
> R6RS requires 24 bits, a compromise (as I am told) between CL's 16
> and the 26 or more bits provided by extant implementations.
The R6RS requires effectively unbounded exact integers, but (like CL)
still designates a portion of these integers to be fixnums. ("...
implementations must support exact integer objects and exact rational
number objects of practically unlimited size and precision" and "A
fixnum is an exact integer object that lies within a certain
implementation-dependent subrange of the exact integer objects".) This
is what I was referring to when I spoke of turning deliberate
underspecification into a feature.
>> If program authors wish to perform arithmetic on small integers
>> with a
>> guarantee of performance, they should write their program
>> with the semantics they desire and use an implementation that will
>> guarantee optimization of their program. If this is not possible in
>> portable Scheme, then we really should be looking for the features
>> that will enable this style of development.
> Note that the above distinction is one of semantics, not of
> There is no guarantee that a Scheme with %bignums has fixnums; it
> have nothing *but* bignums in the implementation sense. What counts
> is whether an arithmetic operation on exact integers might produce an
> inexact value.
Exactly. I don't think my view of how programs ought to be written
precludes implementations which don't have bignums; in fact, I'd
rather that program authors explicitly specify that they need
unlimited-size integers, or specify the limited precision that is
required so that optimizations can be done given this information.
Programs which a required integer range will either work correctly on
a given Scheme, or fail to run immediately because the implementation
does not support the range of exact integers that is required for the
program - but in no case would a program's meaning be dependent on an
implementation-specified integer range.
brian at mastenbrook.net
More information about the r6rs-discuss