[squeak-dev] Re: [BUG] [ :a | ] value: 1

L Peter Deutsch lpd at major2nd.com
Wed Dec 16 17:48:29 UTC 2009


Good Heavens.  To think that that something like this would surface after
all these years....

I agree with Lukas.  The block should return nil.  The ANSI standard is
broken -- the fewer special cases a standard has, the better.

I didn't write the Smalltalk source-to-bytecode compiler, and if I had, I
would have made it return nil if I had had my wits about me.

OTOH, Dan may know of a historical reason why things were done this way --
perhaps there's some fairly common usage pattern that I've forgotten that
makes the return-the-last-argument definition worthwhile.

I agree that changing this is likely to break code.  All the same, I am
somewhat in favor of changing it in the ANSI standard.  If that is done, I
would hope someone would create a tool to do a pass over Smalltalk source
code and browse any occurrences of the problematic construct.  (Fixing them
automatically might not be a good idea, since the value that the block
returns might not actually be used, and if not, no fix would be needed.)
Fortunately, this is an example where it's easy, if a little unsightly, to
write code so that it will work under either interpretation (by explicitly
include the desired return value in the block).

						L Peter Deutsch

P.S. Writing standards is really very tricky.  If one writes a standard too
early, it's likely to get something important wrong simply from not enough
experience; but if you write it too late, it may be impossible to get
implementations to follow it, or the standard may have to compromise on
quality to conform to the implementations.  A depressing example of this is
HTML5, where I'm told the standards committee pretty much caved to whatever
the major browsers had actually done, regardless of how poorly designed it
was.
----------------------------------------------------------------



More information about the Squeak-dev mailing list