[self-interest] Re: blocks

Jecel Assumpcao Jr jecel at merlintec.com
Thu Nov 20 22:49:50 UTC 2003


On Thursday 20 November 2003 19:30, Steve Dekorte wrote:
> On Nov 20, 2003, at 12:35 PM, Jecel Assumpcao Jr wrote:
> > [I'll rewrite your example in Smalltalk]
>
> I don't understand why this is simpler. Could you explain? It's not
> important, I'm just confused and would prefer not to be. :-)

Not simpler - it looks almost exactly the same. Yet under the covers 
there is all the complexity I was talking about with four or five 
different objects (which aren't obvious from reading the source).

My wild guess was that Io might also not be that simple when seen from 
the perspective I was talking about.

> Here's a simplified Io version:
>
> add = method(n, block(x, x + n))
> a = add(10)
> b = add(20)
> a(10) print
> b(10) print

That is shorter, but how many runtime objects does this create? One less 
than the original example, obviously. I counted seven [ignoring 
integers: method( , add( , block( , add( , block( , a( , b( ]. Most 
users would probably just count the two block( ones and ignore the 
rest.

-- Jecel



More information about the Self-interest mailing list