[squeak-dev] Re: [BUG] [ :a | ] value: 1
renggli at gmail.com
Wed Dec 16 17:44:31 UTC 2009
> :) :) This is funny. VisualWorks has exactly the same bug^H^H^Hfeature.
> And if you look at the ANSI standard (ok, this is from the draft, but it is
> essentially the actual document) there is an exception for precisely this
> case, See the last sentence in section 3.4.4 Blocks:
> If a block has no <block body> or no <statements> in its <block body> then
> the value of the block is undefined.
Ok, I did not check that document. I somehow expected that all empty
blocks would return nil.
> Which allows  to be implemented as e.g. [Random new next]. In fact both
> VisualWorks and Squeak answer the last argument:
> [:a ] value: 1 1
> [:a :b|] value: 1 value: 2 2
> [:a :b :c :d :e :f :g :h| ] valueWithArguments: (1 to: 8) 8
> [:a | nil] value: 1 nil
> [:a :b| nil] value: 1 value: 2 nil
> At least it is consistent whether the block is inlined or not ;)
> 1+2 ifNotNil: [:arg|] 3
> It as ever been so.
Thank you for the additional insight. I learned something new on the
Smalltalk semantics today :-)
I will fix my code then.
> P.S. I'm caught between wanting to fix it and wanting to let sleeping dogs
> lie. I'd like to know what all the other dialects do. If a substantial
> majority have the same curio I think we have to live with this, uh,
> ornament. Just to be clear, making it a preference is a sick joke on my
I think we'd better let it sleep. In my image I have 61 empty blocks
with one or more argument. Some of them might depend on that hidden
More information about the Squeak-dev