Upper case global variable?

Is there a restriction when naming global variables to be shared between
java and jruby?

I’m using the jsr223 way and if I do

engine.put(“Logger”, logger), from jruby, $Logger is nil.
-
Begins with Upper case

If I use

engine.put(“logger”, logger), from jruby, $logger is not nil.

In reading the ruby documentation, it seems that global variables can
have uppercase names.

Budyanto H. wrote:

Is there a restriction when naming global variables to be shared between
java and jruby?

I’m using the jsr223 way and if I do

engine.put(“Logger”, logger), from jruby, $Logger is nil.
-
Begins with Upper case

If I use

engine.put(“logger”, logger), from jruby, $logger is not nil.

In reading the ruby documentation, it seems that global variables can
have uppercase names.

I’m using jruby 1.4

Thanks…yah the 1.5 seems to work better.

On Fri, Mar 5, 2010 at 12:42 PM, Budyanto H. [email protected]
wrote:

engine.put(“logger”, logger), from jruby, $logger is not nil.

In reading the ruby documentation, it seems that global variables can
have uppercase names.

Would you please use JRuby 1.5.0.dev, whose snapshots are at
http://ci.jruby.org/snapshots/? There should not be any limitation for
global var names, but in JRuby 1.4.0, regex to judge Ruby variable
names wasn’t correct. If you want to stay on JRuby 1.4.0, choosing
transient local variable behavior, see
http://kenai.com/projects/jruby/page/RedBridge#Local_Variable_Behavior_Options,
would work. In this case, global variables have a name start with “$”
even in Java, so you need to rewrite:

engine.put("$Logger", logger);

-Yoko


Posted via http://www.ruby-forum.com/.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs