[squeak-dev] Temporary Variables and Blocks

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Temporary Variables and Blocks

Anthony Kaufman
Hi, I've been programming smalltalk for a couple of years (VisualWorks  
for the most part) and recently ran into something I'm not quite sure  
what to do with:

callbacks := OrderedCollection new.
(Array with: 1 with: 2 with: 3) do: [ :each | callbacks add:  
[ Transcript show: each asString ] ].
callbacks do: [ :each | each value ]

In Squeak, my transcript shows 333 while in VisualWorks, 123 which I  
would expect. What's going on here and is there anything I can do  
about it? I'm sure this question isn't a new one but I wasn't able to  
articulate my Google and mailing list searches in such a way that gave  
me an answer.

Thanks,
Anthony

Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Re: Temporary Variables and Blocks

Andreas.Raab
Hi Anthony -

This issue is in the process of being fixed. If you fetch the latest VM
from SqueakVM.org and use the following image it will work:

http://squeakvm.org/win32/release/Squeak-3.10.2-Closures.zip

This is a preview-image for closure support.

Cheers,
   - Andreas

Anthony Kaufman wrote:

> Hi, I've been programming smalltalk for a couple of years (VisualWorks
> for the most part) and recently ran into something I'm not quite sure
> what to do with:
>
> callbacks := OrderedCollection new.
> (Array with: 1 with: 2 with: 3) do: [ :each | callbacks add: [
> Transcript show: each asString ] ].
> callbacks do: [ :each | each value ]
>
> In Squeak, my transcript shows 333 while in VisualWorks, 123 which I
> would expect. What's going on here and is there anything I can do about
> it? I'm sure this question isn't a new one but I wasn't able to
> articulate my Google and mailing list searches in such a way that gave
> me an answer.
>
> Thanks,
> Anthony
>
>


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: Temporary Variables and Blocks

Anthony Kaufman
Great, thank you Andreas.

On Jun 15, 2009, at 3:49 PM, Andreas Raab wrote:

> Hi Anthony -
>
> This issue is in the process of being fixed. If you fetch the latest  
> VM from SqueakVM.org and use the following image it will work:
>
> http://squeakvm.org/win32/release/Squeak-3.10.2-Closures.zip
>
> This is a preview-image for closure support.
>
> Cheers,
>  - Andreas
>
> Anthony Kaufman wrote:
>> Hi, I've been programming smalltalk for a couple of years  
>> (VisualWorks for the most part) and recently ran into something I'm  
>> not quite sure what to do with:
>> callbacks := OrderedCollection new.
>> (Array with: 1 with: 2 with: 3) do: [ :each | callbacks add:  
>> [ Transcript show: each asString ] ].
>> callbacks do: [ :each | each value ]
>> In Squeak, my transcript shows 333 while in VisualWorks, 123 which  
>> I would expect. What's going on here and is there anything I can do  
>> about it? I'm sure this question isn't a new one but I wasn't able  
>> to articulate my Google and mailing list searches in such a way  
>> that gave me an answer.
>> Thanks,
>> Anthony
>
>


Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Re: Temporary Variables and Blocks

Bernd Elkemann
In reply to this post by Anthony Kaufman
Hi!
Agreed, real closures support is the way to go.
But if you already have an application integrated into your
older-version image you might want to try this workaround:

callbacks := OrderedCollection new.
(Array with: 1 with: 2 with: 3) do: [ :each | callbacks add: (Compiler
evaluate:'[ Transcript show: ',each asString,' asString ]') ].
callbacks do: [ :each | each value ]

Is this what you meant?

Greetings!

Anthony Kaufman schrieb:

> Hi, I've been programming smalltalk for a couple of years (VisualWorks
> for the most part) and recently ran into something I'm not quite sure
> what to do with:
>
> callbacks := OrderedCollection new.
> (Array with: 1 with: 2 with: 3) do: [ :each | callbacks add: [
> Transcript show: each asString ] ].
> callbacks do: [ :each | each value ]
>
> In Squeak, my transcript shows 333 while in VisualWorks, 123 which I
> would expect. What's going on here and is there anything I can do about
> it? I'm sure this question isn't a new one but I wasn't able to
> articulate my Google and mailing list searches in such a way that gave
> me an answer.
>
> Thanks,
> Anthony
>
>