[self-interest] Re: blocks
Steve Dekorte
steve at dekorte.com
Thu Nov 20 21:30:16 UTC 2003
On Nov 20, 2003, at 12:35 PM, Jecel Assumpcao Jr wrote:
> It certainly does work, but I wouldn't call it simple. Since Self
> doesn't allow non-lifo blocks, I'll rewrite your example in Smalltalk
> instead:
>
> MyObject>>add: n
> ^ [:x | x + n]
>
> a := myObject add: 10.
> b := myObject add: 20.
>
> Transcript show: (a value: 10).
> Transcript show: (b value: 10).
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. :-)
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
-- Steve
More information about the Self-interest
mailing list