Post Reply 
Evaluation of variables in 50g
05-20-2014, 05:38 PM
Post: #1
Evaluation of variables in 50g
While developing newRPL I stumbled upon this "feature" on the 50g:

According to the AUR:
Quote:Evaluating Local Names
Local names are evaluated differently from global names. When a global name is evaluated, the object stored in the corresponding variable is itself evaluated. (You’ve seen how programs stored in global variables are automatically evaluated when the name is evaluated.)
When a local name is evaluated, the object stored in the corresponding variable is returned to the stack but is not evaluated. When a local variable contains a number,the effect is identical to evaluation of a global name, since putting a number on the stack is equivalent to evaluating it. However, if a local variable contains a program, algebraic expression, or global variable name — and if you want it evaluated — the program should execute EVAL after the object is put on the stack.

So, with global variables, for example I write:

Code:

4 'X' STO 'X' 'A' STO 'A' 'B' STO

Then doing:
Code:

'B' EVAL

Should EVAL B, but per the AUR, the contents of B will be evaluated, which evals to 'X' which will in turn be evaluated and give 4 as a final result. This works as expected.

Now doing:
Code:

'X+1' 'A' STO 'B' EVAL

Should EVAL B, which gives 'A' and its contents evaluated 'X+1' = 5.
But the symbolic is NOT evaluated, resulting in 'X+1' on the stack. Pressing EVAL does indeed return the expected 5. Why is the EVAL not executed automatically?
Are there some objects for which auto EVAL is disabled? Is this documented anywhere?

Thanks for the help.
Claudio
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Evaluation of variables in 50g - Claudio L. - 05-20-2014 05:38 PM



User(s) browsing this thread: 1 Guest(s)