Re: Thoughts on eval()

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

This is the type of evaluate() I prefer:

It is neccessary that it can be used with official interpreter (full speed one).
So if you wanted to use evaluate() function you would include eval.e file. (Along
with this file would come other PD source files which are required to parse,
execute the evaluate() string.)

If it crashed it would have to return crash line, column and message, same as
normal interpreter.

This evaluate would then be able to execute for example scripting (macro)
language of an application. so that this application can run at full speed with
official interpreter, and runs slow only when using evaluate().

evaluate() would for me also be very useful for debugging purposes. Now I have
to write my own scripting language (very simple one) if I want to execute
something while my program is running. I could just use evaluate().


Example:

include eval.e
Void = evaluate ("include myfile.e\nmyfunc()")

or maybe even better but more complicated:

include eval.e
p = parse ("include myfile.e\nmyfunc()")
Void = execute (p)



Matt Lewis wrote:
> 
> 
> I've been thinking a bit about this, and I think I see a way, although
> there are a few implementation details that will have to be worked out.
> 
> I think that I'd add a new keyword, "eval", which would be a function 
> taking a sequence, which is just plain text source code.  I can probably
> 'inject' this into the scanner/parser stream, and then put it into its
> own special SubProgram to be executed.  It would probably be like having 
> a separate TopLevel SubProgram, where you could do whatever, including 
> defining new routines (which could be called from subsequent calls to
> eval).
> 
> The function would return 1 if no [compile-time] errors happened, or 0 
> if errors did happen (like perl)--run-time errors would be handled 
> normally.
> 
> Obviously, use of eval() would break the preprocessor.
> 
> Matt Lewis
>

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

Search



Quick Links

User menu

Not signed in.

Misc Menu