Giter Site home page Giter Site logo

Comments (5)

bovi avatar bovi commented on September 10, 2024

Hi pbosetti, yes I know about this issue. At the moment the evaluation is done inside of a proc object. So the scope is only per evaluation but don't least to the next evaluation. I'm wondering if there is a way to execute code in a global context. The code in questions is:

/* evaluate the bytecode */
mrb_return_value = mrb_run(mrb_interpreter,
  /* pass a proc for evaulation */
  mrb_proc_new(mrb_interpreter, mrb_interpreter->irep[byte_code]),
  mrb_top_self(mrb_interpreter));

Any ideas what function in mruby is allowing to execute code in the highest scope?

from mruby.

pbosetti avatar pbosetti commented on September 10, 2024

Hi Daniel,
Whoa, the problem looks interesting: mruby traded the global context in order to improve its use à la Lua, and looks like you found the first shortcoming...
I'll try to look at the problem. I think it's an important one, actually, if one plans to use mruby as an embedded interpreter...

Cheers,
Paolo

On May 14, 2012, at 10:53 PM, Daniel Bovensiepen wrote:

Hi pbosetti, yes I know about this issue. At the moment the evaluation is done inside of a proc object. So the scope is only per evaluation but don't least to the next evaluation. I'm wondering if there is a way to execute code in a global context. The code in questions is:

/* evaluate the bytecode */
mrb_return_value = mrb_run(mrb_interpreter,
 /* pass a proc for evaulation */
 mrb_proc_new(mrb_interpreter, mrb_interpreter->irep[byte_code]),
 mrb_top_self(mrb_interpreter));

Any ideas what function in mruby is allowing to execute code in the highest scope?


Reply to this email directly or view it on GitHub:
#133 (comment)

from mruby.

pbosetti avatar pbosetti commented on September 10, 2024

@bovi: I was looking at the mrb_f_require() in kernel.c: right now (9882fac) it is a dummy method always returning nil. I am not sure about how to implement this method (and looking at the corresponding one in CRuby source is not helping too much either). Nonetheless I am really curious to see how @matz will fill it, because I am pretty sure that this will give us a good example on how to add a bytecode to the top-level scope, don't you think?

from mruby.

bovi avatar bovi commented on September 10, 2024

@pbosetti actually I would believe mrb_f_eval_m() would be the optimal starting point if it would be available. At least this is how the IRB is usually implemented. But I'm wondering if @matz will actually allow eval inside of the final mruby. It would of course be awesome to have it on-demand and cut it out in case you need a small size mruby version but I guess that might be quite a task to do.

from mruby.

matz avatar matz commented on September 10, 2024

I will fix this. I have to prepare a place to hold top-level local variable information.

from mruby.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.