Latest updates

Dan Ingalls DanI at wdi.disney.com
Mon Nov 9 01:01:08 UTC 1998


Folks -

I have just released 19 new updates.  There is not a lot of significant stuff here -- mainly gradual preps for 2.3.   The most significant items are pane resizing for morphic windows, a wavelet transform, and a new coercion package.

New coercion package?  That's right!
I had to bite my tongue during the Double Dispatch discussion ;-).

I have not gone to Double Dispatch.  I simply can't feel good about adding over a hundred methods to the system.  Instead, I have folded the old adaptToType: and adaptType methods into a single method described below.  This has a number of beneficial effects
	1.  The number of methods is halved
	2.  The entire AxB conversion situation can be examined in a single method
	3.  Collections can be dealt with without having to create intermediate structures

If people want to peek ahead without doing a full update, they can look at updates 386 and 387.

I should tell you that there is one further coercion feature yet to come in 2.3:  I have reworked the VM so that before failing arithmetic and comparisons, it checks for the situation of Integer op Float.  In this case it does the conversion in C and proceeds in the twinkling of an eye.  This greatly accelerates the dominant use of coercion.

	- Dan
---------------------------------
P.S. Here's the preamble from the coercion update in case you want a short summary...

This changeSet implements a new arithmetic coercion package for Squeak, based on a single coercion message for every pair of types.  The pattern is as follows:

If there is a failure of 
	self<Type2> op: arg<Type1>
then it is handled by
	^ arg adaptToType2: self andSend: #op:
and this is resolved by a coercion method such as
	<type1> adaptToType2: aType2 andSend: selector
		"If I am involved in arithmetic with a Type2, convert us first."
		^ aType2 coerced perform: selector with: self coerced

Each such method exactly summarizes the coercion between type1 and type2.

The coercions supported include arithemtic (+ - * / // \\) and comparison (< = > <= >=) between
	Integer
	Fraction
	Float
	Point
with arithmetic also extended to Collections.  The extension to collections includes scalars with collections and commensurate sequenceable collections.

The number of coercion messages is less than N squared, where N is the number of arithmetic types.  This compares to M * (N squared) for double dispatching, in the case that M different arithmetic operations are being supported (we have M = 11 for arithmetic plus comparisons).  The actual number is less owing to sharing by inheritance.

The entire arithmetic family above is accomplished with only 18 small methods.  This compares to 26 in the previous Squeak coercion, in which Points were not fully supported, and no collections were.  It compares to over a hundred methods in a full double dispatch solution.





More information about the Squeak-dev mailing list