[Pharo-dev] [squeak-dev] last block arg as implicit return value?
eliot.miranda at gmail.com
Mon May 12 13:17:31 EDT 2014
On Mon, May 12, 2014 at 10:05 AM, Nicolas Cellier <
nicolas.cellier.aka.nice at 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 at gmail.com>:
> >> | myBlock |
>> >> myBlock := [ : arg1 : arg2 | ].
>> >> myBlock value: 'hello' value: 'there'
>> Because the block isn't returning a value and the last line is calling
>> the block.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Pharo-dev