Who wants full block closures and why?
Dwight Hughes
dwighth at ipa.net
Sat Jul 17 21:01:22 UTC 1999
Benoit St-Jean wrote:
>
> At 15:54 99-07-17 -0400, you wrote:
>
> >Non-cute example:
> >
> >| blockArray dataArray |
> >blockArray := Array new: 5.
> >dataArray := #( 'Apple' 'Orange' 'Grape' 'Lemon' 'Kiwi').
> >1 to: blockArray size do: [ :index |
> > blockArray
> > at: index
> > put: [ dataArray at: index ] ].
> >^ (blockArray at: 2) value
>
> I got curious about that code and tried it on several Smalltalk versions.
> Here are the results:
>
> Dolphin : Subscript out of bounds error (Array>>at:)
Interestingly, if you run Dave's second set of code
| blockArray dataArray |
blockArray := Array new: 5.
dataArray := #( 'Apple' 'Orange' 'Grape' 'Lemon' 'Kiwi').
1 to: blockArray size do: [ :index |
blockArray
at: index
put: ([ :n |
[ dataArray at: n ]
] value: index) ].
^ (blockArray at: 2) value
(which he created to get the answer 'Orange' in IBM VAST 4.5) in Dolphin
2.1 you will get 'Kiwi'. The first under Dolphin 2.1 gives "Index 6 is
out of bounds". Personally, I find 'Orange' to be the answer I would
expect from the first test code.
-- Dwight
> Smalltalk Express : primitive fails in Arrat>>at:
> VSE 3.1 : anwers 'Orange'
> VisualWorks 2.5.1 : answers 'Orange'
> VisualWorks Non-Commercial 3.0 : answers 'Orange'
> VisualWorks Beta 5i : raises a SubscriptOutOfBoundsSignal in Core::Array>>at:
> VisualAge for Smalltalk 4.5 : answers 'Kiwi'
>
> Who's right? :)
>
> What's is the ANSI draft saying about such a case?
More information about the Squeak-dev
mailing list
|