APL in Squeak [was: RE: Matrix class?]

Dan Ingalls Dan.Ingalls at disney.com
Fri May 4 00:32:52 UTC 2001


"Raab, Andreas" <Andreas.Raab at disney.com> wrote...
>For what purpose?! There's more than one interpretation of "Matrix" ;-) Here
>are a few we have:
>
>* Array2D
>This gives you a general 2D collection.
>
>* MatrixTransform2x3
>This gives you a 2x3 matrix transform for use with all sorts of 2D graphics.
>
>* B3DMatrix4x4
>This gives you a general 4x4 matrix transform for use with all sorts of 3D
>graphics.

This reminds me of one of my favorite show-off projects for Smalltalk, but this time, I can't for the life of me find my old code.  It's like the "LISP in one page" demo, only it's...

APL in 3 pages
The idea is that most of APL consists of a general array class (basically an element array plus accessor state), a few coercion rules, and a bunch of math functions.  Once you have designed these, you can do essentially everything in Squeak that you can in APL, except with readable method names.

It's a fun project if anyone has an interest.  I had it in the back of my mind the last time I rewrote Squeak's arithemtic coercion mechaism.

	- Dan

PS:  Those of you into APL will know that commercial implementations get quite a bit of extra performance by "dragging and beating" -- essentially lazy evaluation.  It turns out that Squeak is good at doing this as well, with no need to get down and dirty in the VM.  Every method just returns an object that only computes its answer on demand.  The results can be spectacular when 'N squared last' runs just as fast as 'N last squared', even if N is an array of 10000 elements.






More information about the Squeak-dev mailing list