saying arrays

William R Burdick burdick at
Tue Nov 26 02:22:22 UTC 1991

One of the advantages of Lisp is that you can 'say' data.  This saves
programming time but more importantly, it makes code easier to read ('(a
b c) is a bit easier to read than (cons a (cons b (cons c nil)))).  An
even more useful construct is the 'list' function, because it is more
powerful than literal lists, because you can compute the values of the
list at runtime and it's only slightly harder to read.  Perhaps better
than 'list' is the backquote macro, because  it looks more like a
literal list.

You can do this in Self with objects that have named slots, but you
can't 'say' an array.  I think it would be a good idea to add a
construct like this.  The construct I propose is syntactically simple:

say-array: '{' opt-stmt-list '}'

This would make a computed array.  Implementation is simple too -- it's
just like the '[' and ']' words in PostScript: the array is (for the
most part) just a copy of the top elements of the stack.

One really useful application of this construct to use computed arrays
as initializers, like this:

window cloneWith: { curTitle. 0 at 0 extent: 100 at 100 },

where curTitle has been computed at runtime.

This could not be done with a literal object, because curTitle needs to
be computed at run time.

Also, I'm not really clear on why expressions in object literals can't
be evaluated in the currently active context in a similar manner; the
data slots of the new object would also just be a stack copy.

	-- Bill

More information about the Self-interest mailing list