[ENH] floatGlobals-ls

Richard A. O'Keefe ok at cs.otago.ac.nz
Mon Sep 20 03:01:26 UTC 2004


"Lex Spoon" <lex at cc.gatech.edu>
	The only issue I can think of is that it adds three new global
	variables, but these seem like nice ones to have around, and these
	concepts actually are global to all code.

......
	Adds globals variables Infinity, NegativeInfinity, and NaN.  This makes
	all floats print out to something that is re-compilable"
	
Why not just add
    Float class>>
    negativeInfinity
        ^Infinity negated
to Float, and then make the floats in question print as
	(Float infinity)		"not Infinity"
	(Float negativeInfinity)	"not NegativeInfinity"
	(Float nan)			"not NaN"
or even just
	(Float infinity)
	(Float infinity negated)
	(Float nan)
	(Float nan negated)

Of course, I have to point out that NEITHER the change set in question
NOR my proposed revision succeeds in the aim of making all floats print
out as something that evaluates to a number with the same bit pattern,
because there are 2*(2**53-1) NaN values.  For that we'd need
(Float nan: 'hex string') or something like that.

I really can't feel happy about adding three globals.

I'm especially unhappy about this because ANSI Smalltalk mandates
*three* floating-point classes (FloatE, FloatD, and FloatQ) and
*each* of them would want its own three global variables, because
FloatE infinity (if ANSI had it) could not be the same object as
FloatD infinity.

This is of particular interest because it's clear that Squeak _does_
have two floating-point types.  There's "Float" and there's "element
of a FloatArray".  (Anyone else find it confusing that the elements
of FloatArrays are not really Floats?)  Float is roughly FloatD and
FloarArray is roughly packed array of FloatE.  If this were cleaned
up by having
	FloatE		class
	FloatD		class (current Float)
	Float		global, bound to FloatD
	FloatEArray	class (current FloatArray)
	FloatDArray	class
then having globals for Infinity and NaN would really be a pain.




More information about the Squeak-dev mailing list