[squeak-dev] The Trunk: Kernel-nice.1260.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Aug 28 16:52:04 UTC 2019


Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.1260.mcz

==================== Summary ====================

Name: Kernel-nice.1260
Author: nice
Time: 28 August 2019, 6:50:57.499373 pm
UUID: f05b8d6f-4211-c84b-89b5-fec01139f4f8
Ancestors: Kernel-nice.1259

Provision for the case when we disallow mixed SmallInteger/Float arithmetic/comparison in primitives.

Since (rcvr positive) is implemented as self >= 0 (in Number), it would trigger another Float>=SmallInteger comparison, that will primitiveFail, trigger another adaptToFloat:andCompare: etc... (infinite loop)

There are other possible solutions like defining Float>>positive, but it sounds more reasonable to be very careful in this method which specifically handle primitive failure, rather than delegating such care.

=============== Diff against Kernel-nice.1259 ===============

Item was changed:
  ----- Method: Number>>adaptToFloat:andCompare: (in category 'converting') -----
  adaptToFloat: rcvr andCompare: selector 
  	"If I am involved in comparison with a Float, convert rcvr to a
  	Fraction. This way, no bit is lost and comparison is exact."
  	
  	rcvr isFinite
  		ifFalse: [
  			selector == #= ifTrue: [^false].
  			selector == #~= ifTrue: [^true].
  			rcvr isNaN ifTrue: [^ false].
  			(selector = #< or: [selector = #'<='])
  				ifTrue: [^ rcvr positive not].
  			(selector = #> or: [selector = #'>='])
+ 				ifTrue: [^ rcvr >= 0.0].
- 				ifTrue: [^ rcvr positive].
  			^self error: 'unknow comparison selector'].
  
  	"Try to avoid asTrueFraction because it can cost"
  	self isAnExactFloat ifTrue: [^rcvr perform: selector with: self asExactFloat].
  	selector == #= ifTrue: [^false].
  	selector == #~= ifTrue: [^true].
  	^ rcvr asTrueFraction perform: selector with: self!



More information about the Squeak-dev mailing list