[squeak-dev] Re: [Vm-dev] Re: Float hierarchy for 64-bit Spur
David T. Lewis
lewis at mail.msen.com
Mon Nov 24 04:09:03 UTC 2014
On Fri, Nov 21, 2014 at 02:30:59PM +0100, Bert Freudenberg wrote:
> To be abstract, or to be concrete, that is the question.
> Coming back to Eliot's proposal:
> > modify class Float to be an abstract class, and add two subclasses, BoxedFloat and SmallFloat, such that existing boxed instances of Float outside the SmallFloat range will become instances of BoxedFloat and instances within that range will be replaced by references to the relevant SmallFloat.
> > [...]
> > An alternative [...] is to add a superclass, e.g. LimitedPrecisionReal, move most of the methods into it, and keep Float as Float, and add SmallFloat as a subclass of LimitedPrecisionReal.
> +------- BoxedFloat
> +------- SmallFloat
> +------- Float
> +------- SmallFloat
> The actual question was if the class named "Float" (as used in expressions like "Float pi") should be concrete or abstract.
> I strongly agree with Eliot's assessment that making Float the abstract superclass is best. What we name the two concrete subclasses is bikeshedding, and I trust Eliot to pick something not too unreasonable.
I also agree. The name "Float" suggests the concept of floating point arithmetic.
There are many different ways to implement that concept (*). But for all of the
possible concrete implementations of floating point numbers, the name "Float"
makes sense in the abstract.
In Squeak, all instances of "Float" (in the abstract sense) are currently
implemented as 64-bit doubles (instances of class Float) or 32-bit singles
(hidden within FloatArray). Spur-64 will provide an immediate implementation.
Maybe somebody will come up with a class to represent the 32-bit floating point
values in a FloatArray. And maybe someone else will come up with a 128 bit
floating point represention, or something else entirely. But in any case,
it seems natural to have an abstract "Float" to represent all of the concrete
implementations that may prove necessary or useful over time.
So +1 for making Float be the abstract superclass.
(*) As a former field service engineer for Harris Computer Systems, I still
consider the 48-bit floating point format of the H800 series to be superior to
the awkward compromises of 32-bit and 64-bit floating point representations ;-)
See pages 2-2 and 6-1 of the manual for descriptions of the floating point data
formats (I think I have a paper copy of this moldering away in my basement).
More information about the Squeak-dev