[squeak-dev] Serious bug in 3.10

Eliot Miranda eliot.miranda at gmail.com
Thu Jul 31 23:54:27 UTC 2008


On Thu, Jul 31, 2008 at 3:54 PM, Ramon Leon <ramon.leon at allresnet.com>wrote:

>
> > askoh wrote:
> > > | 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
> > >
> > More of a "known limitation" than a bug... due to the fact
> > that squeak
> > does not have proper closures.
> >
> > try
> >
> > | block |
> > block := [:j | Transcript cr; show: j].
> > 1 to: 10 do: [:i | block value: i+1]
> >
> > Keith
>
> I was going to say that, but why does it work using (1 to: 10) do: rather
> than 1 to: 10 do:, seems related to #to:do: being inlined?


Yes.  In the activation of to:do: there is a different counter.  Look at the
implementation of Number>>to:do:.  So while both i's are still the same
lvalue, i is not used by Number>>to:do: either to control the loop
iterations or to to derive the values for the loop.  Only when the loop is
inlined does i become the loop control variable.

HTH


> Ramon Leon
> http://onsmalltalk.com
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20080731/d891073d/attachment.htm


More information about the Squeak-dev mailing list