Two 3.6 issues

Richard A. O'Keefe ok at cs.otago.ac.nz
Wed Oct 29 23:03:45 UTC 2003


Stephane Ducasse wrote:
	I used for my book an old changeset you submitted for Array2D.
	Do you mean that we should replace the current Array2D which is
	ugly and a big hack by your submission.

	Or should we use Matrix. Let us know.


I certainly wouldn't mention Array2D in any book.  A class whose class
comment doesn't tell you what *does* work but lists a bunch of things
that *don't* work and then explains that it's a bad idea to put the
class where in the hierarchy it was put is not a class I would care to
have to explain to anyone.

The central problem with Array2D is that one normally thinks of a
2D array in terms of "array at: row at: column" but Array2D instead
talks about "array at: x at: y", which reverses the conventional
vertical/horizontal metaphor.  Unfortunately, Array2D is not consistent
in its use of "x y": the methods #rowAndColumnValuesDo: and
#rowsAndColumnsDo: use row/column words.  The *really* nasty thing is
that
    a := Array2D width: 2 height: 3.
    a rowsAndColumnsDo: [:row :column | a at: row at: column put: 0].
crashes, because while #rowsAndColumnsDo: reports row then column,
#at:at:put: wants column then row.  Mathematical convention, and the
convention in every programming language I can remember from Fortran on,
is to put row index before column index, even when column major storage
is used.

Matrix would be nice.  In a book, it might be even more instructive to
show how and why one might build Matrix the way it is.




More information about the Squeak-dev mailing list