Some Self ideas

Jecel Assumpcao Jr jecel at merlintec.com
Thu Jan 18 20:36:49 UTC 2001


On Thu, 18 Jan 2001, Bijan Parsia wrote:
> I suppose if it were inlined such that the "c doSomething" and "c
> doSomethignElse" were only conditionally evalated, then the worry about
> delayed evaluation would be moot. But my goodness! At what *price*?
> 	1) Putting a bigger wedge between #ifTrue:ifFalse: etc. and
> 	normal messages. They would *depend* CRUCIALLY on the optimization
> 	for their *semantics*.

Actually, the only value of the original proposal would be to make
#ifTrue:ifFalse *less* different than other messages. Right now the
compiler has to know about this message and handle it as a special case.

Note that

      x > 0 ifTrue: -1 ifFalse: 0

would actually perform much worse than

      x > 0 ifTrue: [-1] ifFalse: [0]

in Squeak since having the compiler treat the latter as a special case
allows it to optimize everything (specially the costly block creations)
away. Self has two compilers (though the term has a different meaning
there than it does in Squeak) and the first would generate better code
for the first variation since it would not optimize the block creation
stuff while the second would generate identical code for both
variations. Only the performance of the code generated by the second
compiler matters, so in Self the motivation is simply to make the
language more uniform and easier to learn.

Yes, easier to learn. I can see that having this "feature" might trip
up some novices, but see the Tektronix paper in the Green Book for an
example of how having the compiler check receiver and argument types
for some selectors and not others can be confusing as well.

As long as we are playing with fire, I should mention one other idea
that has been proposed and rejected on this list more than once but
that I enjoy in Self: having blocks ignore extra arguments. Like the
object value == object idea, this too can lead to errors being caught
much later in the game (if at all). The only place that this is really
used in Self is that all collection iteration messages pass their
blocks two arguments: the current value and the current index (or key).
If you only care about the value (the normal case), you just use a one
argument block. If you need the index, then use a two argument block.
Want to ignore the value? Then this doesn't help since it is just a
simple kludge.

-- Jecel





More information about the Squeak-dev mailing list