[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Aha! How to get rid of Blocks in Smalltalk.




> I agree that blocks make Smalltalk the Language significantly more
> complex.

In what regards?

When I have to introduce Smalltalk to new users, I often (depending on the
developer) notice blocks are harder to get used to initially: learning one
generic, powerful construct vs some (well-known) specialized control flow
constructs (if-then-else, while-do, ...). It reminds me of what early
Macintosh developers learned all too soon: easy to use is not necessarily
easy to learn and vice versa.

If I look at blocks from a conceptual or implementation point of view, I
look at different stories as well. Writing a straightforward
recursive-descent interpreter for Smalltalk is easy, and the differences
between methods and blocks are minor: in case of message sends, look up the
method, set up the context and evaluate the method code; in case of methods,
set up the context (create the block closure) and wait till you have to
execute the block code in that context. Once the context has been set up,
the execution part is identical. Matters are (probably) different however if
you want to write a highly optimized VM ...

One of the things I like about Smalltalk is that it strikes a fine balance
(compromise?) between a very declarative feel (objects, their interfaces,
...), and a not too overly operational feel (short methods and blocks). This
does not imply we should stop trying to improve the language, but (good)
hybrid solutions often seem to work best and should not be ruled out.

michel

======

mtilman@acm.org
http://users.pandora.be/michel.tilman