help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] DynamicVariable in a Continuation


From: Paolo Bonzini
Subject: Re: [Help-smalltalk] DynamicVariable in a Continuation
Date: Wed, 25 May 2011 09:35:11 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.10

On 05/24/2011 08:20 AM, Derek Zhou wrote:
Hi All,
It looks like the sematic of DynamicVariable changed not very long ago; it
was based on Notification, but it now just uses a ProcessVariable. Here is a
simple testcase:

DynamicVariable subclass: Seed [
     ].
Eval [
     |b g1 g2|
     b := [:v | v + Seed value].
     g1 := Generator on: [ :g |
         |v|
         v := 0.
         Seed use: 2 during: [
             [ g yield: v.
               v := b value: v ] repeat ]].
     g2 := Generator on: [ :g |
         |v|
         v := 0.
         Seed use: 3 during: [
             [ g yield: v.
               v := b value: v ] repeat ]].
     Transcript nextPutAll: '%1 %2 %3 %4' % {
         g1 next.
         g2 next.
         g1 next.
         g2 next}; nl.
]

It used to yield "0 0 2 3" but yields "0 0 3 3" now. I'd think "0 0 2 3" is
the correct answer; the documantion specifically mentioned stackframes so
the stackframes hopping from the Continuation should affect the variable,
right?

You are correct. The change was made because it was hundreds of time faster to use ProcessVariable, but I missed this use case. I have to think about it. Do you have any suggestion on how to name the classes to keep the current one available, and still provide "real" DynamicVariables?

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]