Differences between 1/ MRI and 2/ IronRuby+JRuby

Hello,

maybe someone can shed some light on that - the question is: is there a
setting to make IronRuby works the same way MRI Ruby does by default for
what I’m describing below ? I don’t think it’s a bug (but well maybe it
is,
just wondering).

Using this script http://gist.github.com/290538 , MRI has a different
behaviour than JRuby or IronRuby.

The script will work just fine in MRI, whereas in JR/IR you’ll get:

(erb):2: undefined local variable or method version' for main:Object (NameError) from :1:ineval’
from /opt/local/share/java/jruby/lib/ruby/1.8/erb.rb:743:in `result’
from binding-error.rb:19

(erb):1: undefined method version' for main:Object (NoMethodError) from C:/IronRuby/lib/ruby/1.8/erb.rb:716:inresult’
from binding-error.rb:19
from :0:in `eval’

It’s just like values.send(:binding) is doing nothing.

any thoughts ?

thanks,

– Thibaut

AFAIK that shouldn’t work in MRI either

  • C:\dev
    » irb
    irb(main):001:0> require ‘erb’
    => true
    irb(main):002:0>
    irb(main):003:0* data = { :version => RUBY_PLATFORM }
    => {:version=>“i386-mingw32”}
    irb(main):004:0>
    irb(main):005:0* class Hash
    irb(main):006:1> def method_missing(method,args)
    irb(main):007:2> if (keys.include?(method) && args.empty?)
    irb(main):008:3> self[method]
    irb(main):009:3> else
    irb(main):010:3
    super
    irb(main):011:3> end
    irb(main):012:2> end
    irb(main):013:1> end
    => nil
    irb(main):014:0>
    irb(main):015:0* x = 42
    => 42
    irb(main):016:0> template = ERB.new <<-EOF
    irb(main):017:0" The value of x is: <%= version %>
    irb(main):018:0" EOF
    => #<ERB:0x26a53e0 @safe_level=nil, @src="#coding:CP850\n_erbout = ‘’;
    _erbout.concat " The value of x is: “; _erbout.concat(( version
    ).to_s);
    _erbout.concat “\n”\n; _erbout.force_encoding(ENCODING)”,
    @enc=#Encoding:CP850, @filename=nil>
    irb(main):019:0> puts template.result(data.send(:binding))
    NameError: undefined local variable or method version' for main:Object from (erb):1 from C:/Ruby/lib/ruby/1.9.1/erb.rb:753:ineval’
    from C:/Ruby/lib/ruby/1.9.1/erb.rb:753:in result' from (irb):19 from C:/Ruby/bin/irb:12:in
    irb(main):020:0>

Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)

On Sat, Jan 30, 2010 at 2:09 PM, Thibaut Barrère

Hey Ivan,

thanks for your answer.

I redid the test on:

And it works on both apparently…

There must be a reason… Which version of Ruby/IRB are you using ?

– Thibaut

mine was on windows with ruby 1.9.1 though… I don’t have a 1.8 around
to
see if that same test works with 1.8 on windows. In 1.9.1 the tweaked
stuff
works too

  • C:\dev
    » irb
    irb(main):001:0> require ‘erb’
    => true
    irb(main):002:0> require ‘ostruct’
    => true
    irb(main):003:0>
    irb(main):004:0* class OpenStruct
    irb(main):005:1> def get_our_own_binding
    irb(main):006:2> binding
    irb(main):007:2> end
    irb(main):008:1> end
    => nil
    irb(main):009:0>
    irb(main):010:0* class Templator
    irb(main):011:1> def self.render(template,values)
    irb(main):012:2> template = ERB.new(template)
    irb(main):013:2> context = OpenStruct.new(values)
    irb(main):014:2> template.result(context.get_our_own_binding)
    irb(main):015:2> end
    irb(main):016:1> end
    => nil
    irb(main):017:0>
    irb(main):018:0* template = <<-EOF
    irb(main):019:0" The value of x is: <%= version %>
    irb(main):020:0" EOF
    => " The value of x is: <%= version %>\n"
    irb(main):021:0>
    irb(main):022:0* puts Templator.render(template, { :version =>
    RUBY_PLATFORM
    })
    The value of x is: i386-mingw32

Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)

On Sat, Jan 30, 2010 at 2:41 PM, Thibaut Barrère

Thanks - that’s probably a 1.8 specific thing… We’ll see what others
have
to say on Monday :slight_smile:

Thanks for your tests!

– Thibaut

Hi Thomas,

It should work as soon as we push the latest source out.

thanks for the update (note that I’m in no hurry on these bugs - I’m
just
pushing what I find as I go, based on the MSI release, and using
workaround
whenever necessary).

cheers,

– Thibaut

It should work as soon as we push the latest source out.

Tomas

From: [email protected]
[mailto:[email protected]] On Behalf Of Thibaut
Barrère
Sent: Saturday, January 30, 2010 5:10 AM
To: ironruby-core
Subject: [Ironruby-core] Differences between 1/ MRI and 2/
IronRuby+JRuby

Hello,

maybe someone can shed some light on that - the question is: is there a
setting to make IronRuby works the same way MRI Ruby does by default for
what I’m describing below ? I don’t think it’s a bug (but well maybe it
is, just wondering).

Using this script http://gist.github.com/290538 , MRI has a different
behaviour than JRuby or IronRuby.

The script will work just fine in MRI, whereas in JR/IR you’ll get:

(erb):2: undefined local variable or method version' for main:Object (NameError) from :1:ineval’
from /opt/local/share/java/jruby/lib/ruby/1.8/erb.rb:743:in `result’
from binding-error.rb:19

(erb):1: undefined method version' for main:Object (NoMethodError) from C:/IronRuby/lib/ruby/1.8/erb.rb:716:inresult’
from binding-error.rb:19
from :0:in `eval’

It’s just like values.send(:binding) is doing nothing.

any thoughts ?

thanks,

– Thibaut

We should be doing an MSI in the next few weeks.

JD

From: [email protected]
[mailto:[email protected]] On Behalf Of Thibaut
Barrère
Sent: Monday, February 01, 2010 9:02 AM
To: [email protected]
Subject: Re: [Ironruby-core] Differences between 1/ MRI and 2/
IronRuby+JRuby

Hi Thomas,

It should work as soon as we push the latest source out.

thanks for the update (note that I’m in no hurry on these bugs - I’m
just pushing what I find as I go, based on the MSI release, and using
workaround whenever necessary).

cheers,

– Thibaut

Tomas

From:
[email protected]mailto:[email protected]
[mailto:[email protected]mailto:[email protected]]
On Behalf Of Thibaut Barrère
Sent: Saturday, January 30, 2010 5:10 AM
To: ironruby-core
Subject: [Ironruby-core] Differences between 1/ MRI and 2/
IronRuby+JRuby

Hello,

maybe someone can shed some light on that - the question is: is there a
setting to make IronRuby works the same way MRI Ruby does by default for
what I’m describing below ? I don’t think it’s a bug (but well maybe it
is, just wondering).

Using this script http://gist.github.com/290538 , MRI has a different
behaviour than JRuby or IronRuby.

The script will work just fine in MRI, whereas in JR/IR you’ll get:

(erb):2: undefined local variable or method version' for main:Object (NameError) from :1:ineval’
from /opt/local/share/java/jruby/lib/ruby/1.8/erb.rb:743:in `result’
from binding-error.rb:19

(erb):1: undefined method version' for main:Object (NoMethodError) from C:/IronRuby/lib/ruby/1.8/erb.rb:716:inresult’
from binding-error.rb:19
from :0:in `eval’

It’s just like values.send(:binding) is doing nothing.

any thoughts ?

thanks,

– Thibaut

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