Comments (5)
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.
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.
@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.
@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.
I will fix this. I have to prepare a place to hold top-level local variable information.
from mruby.
Related Issues (20)
- When `MRB_UTF8_STRING` is enabled, giving byte characters for `String#index` and `String#split` gives wrong results HOT 3
- Parse error with required kwargs and omitted parens
- `NODE_ZSUPER` from deeply nested blocks will result in a truncated digits for block index in `OP_ARGARY` HOT 1
- `NODE_SUPER` / `NODE_ZSUPER` on the top level passes the wrong block index to `gen_blkmove()` which generates `OP_GETUPVAR`
- MSVC: can't use `malloc()` in `string.c` with `WIN32_LEAN_AND_MEAN` HOT 3
- build with build_config.rb w/mruby extensions succeeds but doesn't create SciTE binary HOT 1
- mrb_fixnum returns wrong value if integer is large HOT 1
- Segmentation fault in function get_file in debug.c HOT 3
- Mirror of prettier package for pre-commit is now archived HOT 1
- Assigning to a block variable changes the actual block (thus affecting `block_given?` and `yield`) HOT 3
- `foo :bar {}` is legal in mruby? HOT 1
- method call faile on arm v5 HOT 2
- Calling method_missing with only Kwargs passes arguments incorrectly HOT 3
- Is peephole optimization done by mrb_load_string or only by mrbc? HOT 3
- Planned change patch for `mrb_vm_exec()` HOT 3
- Add an actual `Makefile` to the sources HOT 11
- Double free during GC sweep HOT 1
- mrb_gc_register() may cause GC and collect the object being protected HOT 2
- Detect “Use-after-free” with address sanitizer HOT 5
- Is possible change this line in gc.h ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mruby.