Aha! How to get rid of Blocks in Smalltalk.

Lex Spoon lex at cc.gatech.edu
Sat Apr 22 11:12:08 UTC 2000


Ranjan Bagchi <ranjan.bagchi at frotz.com> wrote:
> > Actually, you only really have to say:
> >
> >               aCollection.do(new BlockLike() {
> > 			int value(int each) {
> > 				return each.doSomething();
> > 			}
> > 		  });
> >
> 
> Maybe I'm missing something, but why is
> 	aCollection do: [:each | each doSomething]
> better?
> 

It's one line instead of four, which means blocks are much more
convenient to use in Smalltakl.  They are also much simpler in
Smalltalk, because you don't have to put all the surrounding static type
information.

In this way, Smalltalk encourages people to play with blocks, while Java
pushes in the other direction.


Otherwise, they mostly do give you the same value, as far as I know.


-Lex





More information about the Squeak-dev mailing list