It seems that in Pharo 3 [:a :b|] value: #first value: #last answers nil whichever compiler you use (Opal or the old one). 2014-05-12 19:17 GMT+02:00 Eliot Miranda <eliot.miranda@gmail.com>:
On Mon, May 12, 2014 at 10:05 AM, Nicolas Cellier < nicolas.cellier.aka.nice@gmail.com> wrote:
I think I remember it was either the first or last parameter that was returned in old implementation
the last. ([:a :b|] value: #first value: #last) == #last
It's a known problem: http://bugs.squeak.org/view.php?id=5793
but I would have thought that this was fixed with Eliot's closure...
I kept the old semantics, trying to rock the boat as little as possible. I just checked the draft standard. The end of 3.4.4 "blocks" reads
"If a block has no <block body> or no <statements> in its <block body> then the value of the block is undefined." I've found the returning the last value bizarre for a while. If others feel strongly we could fix it for 4.6/5.0. But I'd want agreement with Pharo. Marcus what does Opal do with:
[:a :b|] value: #first value: #last
?
Squeak & VW answer #last.
2014-05-12 17:58 GMT+02:00 blake <dsblakewatson@gmail.com>:
| myBlock |
myBlock := [ : arg1 : arg2 | ]. myBlock value: 'hello' value: 'there'
nil
Because the block isn't returning a value and the last line is calling the block.
-- best, Eliot