[self-interest] Re: blocks
Steve Dekorte
steve at dekorte.com
Fri Nov 21 13:25:20 UTC 2003
On Nov 21, 2003, at 4:41 AM, Pablo de Marcos wrote:
> Steve, sorry but in the example [ add = method(n, block(x, x + n)) ]
> i
> don't understand ...
>
> Where does x live?
It is an argument off the block.
> If I invoke
> a = add(10)
> then it signified to execute a method with 1 argument (n) whose
> functionality is to process x+n, but where is x?
No, it's functionality it to return the block "block(x, x + n)". This
is then assigned to the value a. When we call:
a(10)
it activates the block with the argument 10 which is what x is set to.
the block finds n in it's enclosing context which is the locals that
where created when the add method was called.
-- Steve
More information about the Self-interest
mailing list