Re: string_exec()
- Posted by dcuny Mar 06, 2015
- 2111 views
I'm not your slave and trying to guilt trip me into something like this isn't going to work, either.
Kat's comments don't seem to be targeted to anyone specifically.
Matthew's are, and seem to me as both "putting down" and "showing disrespect".
So why is Kat the one being slapped with a Code of Conduct violation here?
In any event, I'm still unclear on the details of the request. So I'm going to try to get clarification again.
Code that is outside of routine definitions effectively goes into a no-name top-level routine. You can think of:
integer a function foo() return 100 end function a=foo()
As effectively:
function foo() return 100 end function procedure __top_level__() integer a a = foo end procedure
If you're asking for something like this:
string_exec("integer a\nfunction foo()\n return 100\n end function\n a=foo()")
it raises the question of where the "run me now" code goes. It can't be inserted into existing top level code, since that's a currently executing scope.
Since you're doing two different things - compiling and executing - you need two different steps. For example:
-- compile foo(), and return the routine_id integer foo_id = compile_func("foo", {}, {"return 100"}) -- compile code to run foo() and set a global variable, then execute it call_proc(compile_proc("run_foo", {"a=foo()"}))
Does this approach make sense?
- David