Dear all,
using Sci-Smalltalk, we found with Natalia that sometimes blocks have
strange behavior :
https://groups.google.com/forum/#!topic/scismalltalk/HmGpTkzLOdQ
I was able to create a more simpler example using only Pharo.
If you try, the following expression, there is no problem:
|state values |
values := (1 to: 10000) collect: [ : t| state := { t. t+1. t+2.}].
(1 to: 10000) do:[:i | (values at:i) at:2].
and you do more iterations, an error appears (Instances of
SmallInteger are not indexable),
because from time to time, an array is replaced by an integer:
|state values |
values := (1 to: 100000) collect: [ : t| state := { t. t+1. t+2.}].
(1 to: 100000) do:[:i | (values at:i) at:2].
and if you move the state variable inside the block, it works again :
| values |
values := (1 to: 100000) collect: [ : t| |state| state := { t. t+1. t+2.}].
(1 to: 100000) do:[:i | (values at:i) at:2].
Same problem in Pharo 3.0 or Pharo 4.0
Regards,
--
Serge Stinckwich
UCBN & UMI UMMISCO 209 (IRD/UPMC)
Every DSL ends up being Smalltalk
http://www.doesnotunderstand.org/