And a method closes over the instvars of the object.

Even if you said that

    at: key put: value
        <statements here>

was equivalent to

[:self :key :value | <statements here>]

you'd still need to qualify that <statements here> has privileged
access to the interior of self. So the equivalent block is more like

[:self :key :value <insert all of the object's instvars> | <statements here>]

(modulo non-local returns, of course)

frank

On 12 January 2012 13:23, Johan Brichau <[email protected]> wrote:
> Hi,
>
> With the exception of any return statement in <statements here>, which should 
> do a non-local return instead of returning from the block.
> I just read an interesting post on why functions (or methods) are not blocks: 
> http://yehudakatz.com/2012/01/10/javascript-needs-blocks/
>
> best,
> Johan
>
> On 10 Jan 2012, at 01:52, James Ladd wrote:
>
>>
>> While implementing Redline Smalltalk it occurred to me that methods and 
>> blocks
>> are the same things, making the use of blocks to represent methods a possible
>> optimisation or simplification to the internal of any Smalltalk 
>> implementation.
>>
>> For example,
>>
>> at: key put: value
>>   <statements here>
>>
>> Is not that different to:
>>
>> at:put: [ :key :value | <statements here> ]
>>
>> Just saying.
>
>

Reply via email to