Re: Version 2.4 and beyond

new topic     » goto parent     » topic index » view thread      » older message » newer message

Kat wrote:
> And exec(sequence) would 
> allow scripted database entries, as would defining the item as a class while 
> the program is still running. Which would be easier for you Rob, 
> exec(sequence) or build_class(sequence)) ?

It is possible to have exec() in the current Euphoria.

procedure setVarsForExec()
    -- the inconvient part
    -- tells exec() what are values of variables
    setExecVar("foo", foo)
    setExecVar("bar", bar)
    ...
end procedure

procedure setVarsFromExec()
    -- the inconvient part
    -- after exec() variales are updated if they was changed
    -- by code in exec()
    foo = getExecVar("foo")
    bar = getExecVar("bar")
    ...
end procedure

procedure execCode(sequence t)
    routine => call via routine_id()
    emulate entire euphoria
    has its own table of variables
end procedure

procedure exec(sequence s)
    t = tokenize(s)
    setVarsForExec()
    for i=1 to length(t)
        execCode(t)
    end for
    setVarsFromExec()
end procedure

It isn't as fast as exec() built-in into interpreter,
but allows the code to be translated to C.

So the only thing that would make exec() easier, is
the ability to reference variables via their name
like routine_id() does. But this would introduce
pointers...

    -- Martin

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu