Thoughts?
---------- Forwarded message ----------
We in the JRuby project are working to get Rails to work successfully. However, the array-indexed block parameter is not currently supported in JRuby:
x = {}
[1,2].each {|x[:foo]|}
This is not used extensively in the Rails code, but it's used enough to cause things to break in JRuby. We have been modifying the above to use a temporary local variable, but obviously it's not ideal. I emailed the Ruby Core list to ask how this behavior is implemented in C Ruby, and Matz's response (below) seems to indicate that it will eventually be unsupported.
So my question is this: Would it not be reasonable to eliminate the few uses of this unusual block parameter format right now? Of course I have selfish motives; this behavior is a bit unusual and we would rather not have to implement it if it will go away in the future. However, we want very much the ability to run Rails in JRuby, and if we must we must.
Thoughts?
x = {}
[1,2].each {|x[:foo]|}
This is not used extensively in the Rails code, but it's used enough to cause things to break in JRuby. We have been modifying the above to use a temporary local variable, but obviously it's not ideal. I emailed the Ruby Core list to ask how this behavior is implemented in C Ruby, and Matz's response (below) seems to indicate that it will eventually be unsupported.
So my question is this: Would it not be reasonable to eliminate the few uses of this unusual block parameter format right now? Of course I have selfish motives; this behavior is a bit unusual and we would rather not have to implement it if it will go away in the future. However, we want very much the ability to run Rails in JRuby, and if we must we must.
Thoughts?
---------- Forwarded message ----------
From: Yukihiro Matsumoto <[EMAIL PROTECTED]>
Date: Mar 27, 2006 12:07 AM
Subject: Re: Tricky block args
To: [EMAIL PROTECTED]
Hi,
In message "Re: Tricky block args"
on Mon, 27 Mar 2006 13:54:58 +0900, "Charles O Nutter" < [EMAIL PROTECTED]> writes:
|We are trying to implement some missing block arg functionality. Could
|someone knowledgable about the more unusual methods of declaring block args
|point us to where in the C code it is implemented? Specifically, the ability
|to specify an array or hash location as the target for a block param:
|
|x = [0]
|[1,2].each {|x[0]|}
The assignment to x[0] is done in assign() function, especially at the
code after /* array set */ comment. It's called from rb_yield_0().
FYI, in the future, block parameters will be restricted to local
variables only, so that I don't recommend using something other than
local variables for the parameters.
matz.
--
Charles Oliver Nutter @ headius.blogspot.com
JRuby Developer @ jruby.sourceforge.net
Application Architect @ www.ventera.com
Charles Oliver Nutter @ headius.blogspot.com
JRuby Developer @ jruby.sourceforge.net
Application Architect @ www.ventera.com
--
Charles Oliver Nutter @ headius.blogspot.com
JRuby Developer @ jruby.sourceforge.net
Application Architect @ www.ventera.com
_______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core