[squeak-dev] Re: Serious bug in 3.10
nicolas cellier
ncellier at ifrance.com
Fri Aug 1 02:08:51 UTC 2008
Ramon Leon <ramon.leon <at> allresnet.com> writes:
>
> > Sent: Thursday, July 31, 2008 3:33 PM
> > To: squeak-dev <at> lists.squeakfoundation.org
> > Subject: [squeak-dev] Serious bug in 3.10
> >
> >
> > | block |
> > block := [:i | Transcript cr; show: i].
> > 1 to: 10 do: [:i | block value: i+1]
> >
> > The above should print ten times. But it only prints the five
> > even numbers.
> > That is a bug isn't it?
> >
> > Aik-Siong Koh
>
> Try this..
>
> block := [:f | Transcript cr; show: f].
> (1 to: 10) do: [:f | block value: f+1]
>
> And you'll see that likely, to:do: is being inlined by the compiler and
> causing something funny like allowing you to increment the loops index var
> causing it to skip a number each iteration.
>
> Ramon Leon
> http://onsmalltalk.com
>
>
Yes but:
block := [:f | Transcript cr; show: f].
(1 to: 10) do: [:f | block value: f+1. block value: f].
does not behave much better...
the 10 loops are performed, but since the blocks share same temporary f, things
are still a bit strange.
You need to use different argument names, NewCompiler or Eliot's closures.
More information about the Squeak-dev
mailing list
|