Re: string_exec()

new topic     » goto parent     » topic index » view thread      » older message » newer message
katsmeow said...

Well, except the programmer cannot see the var table. If you ask for the value of myVariable, it's more likely to crash because the var doesn't exist.

In trace, you can ask for the value of a variable and it'll be displayed. If you ask for a variable that doesn't exist in the current scope, it doesn't crash.

I seem to recall someone asking for this mechanism recently, and reading that Euphoria provided it. So I'll have to look to see how it's implemented.

katsmeow said...

You can of course put anything in the string, that doesn't mean it gets converted to IL code and executes in the scope of where it was called.

I'm not talking about executing as IL. You can write a simple expression parser. If an identifier is followed by an open parenthesis (, the parser knows it's a function, and uses routine_id to find the routine name. If not, it's a variable and it looks in the variable table, using a mechanism similar to trace.

katsmeow said...

Show us. I'll pause taking Tiggr apart for a lil while, to see what you come up with.

Is an expression evaluator what you're after? Note that you can inquire about variables, and call functions, but you can't actually extend the current application by adding new variables and functions.

This solution would work if you're only interested in executing the right hand side of an expression.

- David

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

Search



Quick Links

User menu

Not signed in.

Misc Menu