2 eval - evaluate a string
13 For eval(str), the value of str is to be a string that could be the body
14 of the definition of a function f(). This string may declare local
15 variables and include keywords (while, for, ...) other than the
16 reserved keywords (define, show, help, read, write, show, cd) intended
17 for interactive use or for reading from a file.
19 If str is the empty string "", eval(str) returns the null value.
21 The call to eval(str) may return a value by explicit use of a return
22 statement: "return;" returns the null value, "return expr;" returns the
23 value of expr. If execution reaches the end of str and the
24 value on the execution stack is not null, eval(str) returns that value;
25 otherwise eval(str) returns the most recently saved value.
27 Each time eval(str) is called, a temporary function is compiled from
28 the commands in str, and if there are no syntax errors, this function
29 is then evaluated. If str contains syntax errors, eval(str) displays
30 the scanerror messages and returns the value error(49).
33 > str1 = "2 + 3"; print eval(str1);
36 > i = 10; str2 = "local i = 0; 7; while (i++ < 5) print i^2,:;"
37 > print i, eval(str2), i
40 (The print statements in str2 return the null value, so execution of
41 eval(str2) ends by returning the saved value 7. The global variable
49 The string str in eval(str) should not include a call to itself as in
53 For this str, eval(str) causes an "Evaluation stack depth exceeded" error.
54 Similarly, if str1 = "2 + eval(str2)", str2 should not include a call
61 command, expression, define, prompt