I have a piece of code, which I cannot make running. Please take a look:
"Here we have an ordered collection of closures checking the integer
argument complies some properties."
a := OrderedCollection new.
a add: [:i | i \\ 2 = 0 ].
a add: [:i | i \\ 3 = 0 ].
a add: [:i | i > 6 ].
"I seem there should be returned a closure with 1 argument checking whether
an argument is a product of 3 and 2, which value is larger than 6."
b := a inject: [:i | true ] into: [ :accumValue :item | [:i | ( accumValue
value: i ) and: [item value: i] ] ].
"We dont need the collection anymore, because it's elements are now
referenced from inside b."
a := nil.
> "Why stack overflows?"
> b value: 6.
> b value: 12.
> PS :I'm trying in DVE5.
Because you are using DVE5 ;-)
Dolphin, before D6, didn't have blocks which were "full closures", and so
sometimes the semantics could differ from what you might expect. Seach the
archives for more details.
In D6 blocks have a new implementation with the more general semantics. And
your two test expressions answer false and true respectively. I don't know
whether that's the answer you'd expect, but that's what you get ;-)