Forum: Ruby-core Ruby 1.8 evaluates block argument out of order from other arguments and receiver

Posted by Charles Nutter (headius)
on 2012-11-16 17:35
(Received via mailing list)
Issue #1034 has been updated by headius (Charles Nutter).


This was an artifact of 1.8's interpreter. It should be fixed (which 
would be hard, since iter/blockarg wraps whatever call it goes with) if 
1.8 is open or closed if it is not.
----------------------------------------
Bug #1034: Ruby 1.8 evaluates block argument out of order from other 
arguments and receiver
https://bugs.ruby-lang.org/issues/1034#change-32980

Author: headius (Charles Nutter)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category:
Target version:
ruby -v: Ruby 1.8


=begin
 In Ruby 1.9 and all alternative impls I tested, block arguments are 
evaluated in the order they're encountered in a call. For example:

 a.foo(b, c, &d)

 The expected order would be left to right, a, then b, then c, then d. 
But Ruby 1.8 evaluates in the order d, a, b, c. In a case like the 
following (somewhat contrived) this would have odd side effects:

 x = 0
 (x += 1; a).foo(x += 1, x += 1, &(x += 1, d))

 In 1.8, the two non-block arguments would be 3, 4, while on Ruby 1.9 
and other impls it would be 2, 3 as you'd expect.
=end
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.