EVAL

Calculator Key: Eval

Member Of Menu: 
None
Argument Types: 
Any
Result Type(s): 
Any
Invertible: 
No
Valid In Expression: 
No
Stack Diagram: 
Item1 Item2

This operation takes an item from the stack and evaluates it. For most types of stack items, evaluation does not change anything. For example, if 8 was on the stack before EVAL was executed, the result of EVAL is also 8.

However, for symbols, expressions and programs, the result may be different from the input. If a symbol is on the stack, then this operation will lookup that symbol, traversing directories from the current directory to the HOME directory. If it finds that symbol, it will replace it with the value of that symbol.

If an expression is on the stack, then any symbols in the expression will be evaluated as described above. The value of those symbols will be substituted in the expression. Any operations in the expression will be executed as long as the arguments for those expressions is known (for example a real value and not just a symbol). The final result may still be an expression or may be some other type, like a real, depending on the evaluation of the expression.

If a program is on the stack, then the program is executed. This may actually result in more values being popped off the stack or multiple values being pushed onto the stack. So, the stack diagram above may not be accurate depending on the program.

Note that EVAL will not substitute the values of the global constants e, i and π. If you require that functionality, use the →NUM operation.