'From Squeak3.2alpha of 3 October 2001 [latest update: #4446] on 23 October 2001 at 5:46:05 am'! "Change Set: numberType-sw Date: 23 October 2001 Author: Scott Wallace Fleshes out some details of the Number vocabulary by providing accurate result types and argument types for the method-interrfaces. The benefits will show up immediately in a viewer open on a number -- try, for example, evaluating '123 beViewed'"! !MethodInterface methodsFor: 'initialization' stamp: 'sw 10/23/2001 05:42'! resultType: aType "Set the receiver's resultSpecification to be a ResultType of the given type" resultSpecification _ ResultSpecification new. resultSpecification resultType: aType! ! !NumberType methodsFor: 'initialization' stamp: 'sw 10/10/2001 06:24'! initialize "Initialize the receiver (automatically called when instances are created via 'new')" | aMethodCategory aMethodInterface | super initialize. "Vocabulary replaceNumberVocabulary" "Vocabulary addVocabulary: Vocabulary newNumberVocabulary" self vocabularyName: #Number. self documentation: 'Numbers are things that can do arithmetic, have their magnitudes compared, etc.'. #((comparing 'Determining which of two numbers is larger' (= < > <= >= ~= ~~)) (arithmetic 'Basic numeric operation' (* + - / // \\ abs negated quo: rem:)) (testing 'Testing a number' (even isDivisibleBy: negative odd positive sign)) (#'mathematical functions' 'Trigonometric and exponential functions' (cos exp ln log log: raisedTo: sin sqrt squared tan raisedToInteger:)) (converting 'Converting a number to another form' (@ asInteger asPoint degreesToRadians radiansToDegrees asSmallAngleDegrees asSmallPositiveDegrees)) (#'truncation and round off' 'Making a real number (with a decimal point) into an integer' (ceiling floor roundTo: roundUpTo: rounded truncateTo: truncated)) ) do: [:item | aMethodCategory _ ElementCategory new categoryName: item first. aMethodCategory documentation: item second. item third do: [:aSelector | aMethodInterface _ MethodInterface new conjuredUpFor: aSelector class: (Number whichClassIncludesSelector: aSelector). aMethodInterface argumentVariables do: [:var | var variableType: #Number]. (#(* + - / // \\ abs negated quo: rem: cos exp ln log log: raisedTo: sin sqrt squared tan raisedToInteger: asInteger degreesToRadians radiansToDegrees asSmallAngleDegrees asSmallPositiveDegrees) includes: aSelector) ifTrue: [aMethodInterface resultType: #Number]. (#( @ asPoint ) includes: aSelector) ifTrue: [aMethodInterface resultType: #Point]. (#(= < > <= >= ~= ~~ even isDivisibleBy: negative odd positive) includes: aSelector) ifTrue: [aMethodInterface resultType: #Boolean]. aMethodInterface setNotToRefresh. self atKey: aSelector putMethodInterface: aMethodInterface. aMethodCategory elementAt: aSelector put: aMethodInterface]. self addCategory: aMethodCategory]. " (('truncation and round off' ceiling detentBy:atMultiplesOf:snap: floor roundTo: roundUpTo: rounded truncateTo: truncated) ('testing' basicType even isDivisibleBy: isInf isInfinite isNaN isNumber isZero negative odd positive sign strictlyPositive) ('converting' @ adaptToCollection:andSend: adaptToFloat:andSend: adaptToFraction:andSend: adaptToInteger:andSend: adaptToPoint:andSend: adaptToString:andSend: asInteger asNumber asPoint asSmallAngleDegrees asSmallPositiveDegrees degreesToRadians radiansToDegrees) ('intervals' to: to:by: to:by:do: to:do:) ('printing' defaultLabelForInspector isOrAreStringWith: newTileMorphRepresentative printOn: printStringBase: storeOn: storeOn:base: storeStringBase: stringForReadout) ('comparing' closeTo:) ('filter streaming' byteEncode:) ('as yet unclassified' reduce)" ! ! "Postscript:" Vocabulary replaceNumberVocabulary. !