Bug in BlockContext ?
Samir Saidani
saidani at info.unicaen.fr
Thu Feb 17 14:10:59 UTC 2005
Ok, here a mail for the archive, in case someone has the same
problem. The examples below are obviously bad, the block variable
could not be changed by this way (It's like I write a := 2. b := a. a
:= 1. b. and expect that b equal 1 !). The right way is something
like that :
block := [:a1 | [a1] ].
(block value: 2) value.
(block value: 1) value.
But it seems that we don't need fixTemps for this kind of stuff, this
example works perfectly without. For sure, the fixTemps effect is not
clear for me, but I discovered in the TestBlock example I gave before
that I have to do a fixTemps when I fix the instance variable block :=
aBlock fixTemps, but it doesn't work when I call TestBlock2 on:
... block: ... fixTemps. I thought that it was the same thing, but it
seems not. Don't know why !
Regards,
Samir
Samir Saidani <saidani at info.unicaen.fr> writes:
> Hi Bert,
>
> Thanks for pointing me this out, I found some mails about this closure
> problem. However, I tried this several little examples without success
> :
>
> a := 2.
> block := [:a1 | [a1] ] fixTemps value: a.
> block value.
> a := 1.
> block value.
> -> 2
>
>
> a := 2.
> block := [:a1 | [a1] fixTemps ] value: a.
> block value.
> a := 1.
> block value.
> -> 2
>
> It doesn't work :-(
>
>
> Bert Freudenberg <bert at impara.de> writes:
>
>> Am 15.02.2005 um 15:24 schrieb Samir Saidani:
>>
>>> Hello,
>>>
>>> I'm really not sure if this is a bug, or if I don't understand well
>>> the way a BlockContext works in Squeak
>>
>> I'm sure that must be in the FAQ somewhere - Blocks in regular Squeak
>> are not Closures. A workaround is to manually send fixTemps the block.
>>
>> - Bert -
>>
>>
>>
>
> --
> Samir SAIDANI
> PhD Student in CS / Doctorant en informatique web : http://www.info.unicaen.fr/~saidani
> Universite de Caen - Laboratoire GREYC tel : 02-31-56-74-30
> Equipe MAD - Campus II - 14032 Caen Cedex fax : 02-31-56-76-30
>
>
--
Samir SAIDANI
PhD Student in CS / Doctorant en informatique web : http://www.info.unicaen.fr/~saidani
Universite de Caen - Laboratoire GREYC tel : 02-31-56-74-30
Equipe MAD - Campus II - 14032 Caen Cedex fax : 02-31-56-76-30
More information about the Squeak-dev
mailing list
|