Bug in BlockContext ?

Avi Bryant avi.bryant at gmail.com
Thu Feb 17 14:37:30 UTC 2005


On Thu, 17 Feb 2005 22:30:19 +0800, Yar Hwee Boon <hboon at motionobj.com> wrote:

> Try the following (note that the |a| is important) in a workspace to
> see the effect of #fixTemps:
> 
> ====
> |a|
> a := 1.
> b1 := [a].
> b2 := [a] fixTemps.
> a := 3.
> b1 value + b2 value

Yes, although in this case #fixTemps is making it act *differently*
from how a proper BlockClosure would, whereas the default behavior
would be the same.  Here's a similar example where fixTemps "fixes"
the behavior rather than "breaking" it:

|blocks1 blocks2|
blocks1 := (1 to: 10) collect: [:ea | [ea]].
blocks2 := (1 to: 10) collect: [:ea | [ea] fixTemps].
blocks1 first value + blocks2 first value

For those who use Seaside - every callback in Seaside has #fixTemps
sent to it, which is why code like this works:

html list: items do:
  [:ea |
  html anchorWithAction: [self showItem: ea] text: item name]

The [self showItem: ea] block gets fixTemped so that the value of "ea"
is preserved properly.  Otherwise clicking on any item would display
the last one in the last.

Avi



More information about the Squeak-dev mailing list