1

The code should look like this:

def bring_into_scope(module)
  #here the caller of the method should get methods from +module+
end

class Bar
  def bar_method
    #do stuff
  end
end

class Foo
  def initialize(bar)
    bring_into_scope(bar)

    bar_method
  end
end

I need the functinality because I want to write a library that inlines rust code, so one should be able to write:

class RustAndRuby
  def ruby_method; end

  #this should make all fn's in the rust code available in RustAndRuby
  Rust.code {
    "String with rust code..."
  }
end

Is this possible in ruby? (If you need further information feel free to ask!)

le_me
  • 3,089
  • 3
  • 26
  • 28
  • So what is rust, a class or module. Where is it ? – Sandeep Oct 06 '13 at 22:52
  • 1
    Rust is a programming language. http://rust-lang.org – Ercan Erden Oct 07 '13 at 03:04
  • Rust code needs to be compiled, so `Rust#code` would need to pass the string on to a rust compiler, and that's just the first problem. Next you'll have a binary you need to link the functions to. I've never done this personally, but I know it's possible though unlikely easy. Or, you could write a rust interpreter in Ruby, and then just call that. – Nathan Lilienthal Jul 22 '14 at 05:04

1 Answers1

0

Maybe take a look at this, written by one of the main contributors of Rust.

Nathan Lilienthal
  • 864
  • 1
  • 10
  • 16