:) :) Â 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 part.
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 behavior. Lukas -- Lukas Renggli http://www.lukas-renggli.ch