Re: RPN: a new (old) challenge? Message #7 Posted by ExPPC member on 6 Nov 2001, 11:03 a.m., in response to message #5 by Cameron
There's also the fact that to evaluate a typical
algebraicnotation expression (say: 5*(3+2)/(87)), all
interpreters and compilers I know have to convert
it internally to a form of RPN, because that's the only
way the expression can be evaluated, i.e: whether you
like it or not, the only way you can have 5 times 4 is
to have the 5 inside the processor (5), then the 4 (4), then your processor or software performs the multiplication (*).
There's no way you can have the 5 (5), then have the processor
or software perform the multiplication (*), then make
available the 4 to it (4).
I once wrote a BASIC interpreter. To compute algrebraic
expressions, I had to resort to parsing the expression,
putting the operands and operations in a stack (to cater
for different priorities and parentheses), then evaluated
the different simple subexpressions RPNlike.
An even better example of this being the actual case, even
industrially, can be found in the Sharp PC1211 (a
contemporary of the hP41C in the 80's) User Manual.
That was a neat, smart handheld machine programmable in
BASIC, and on page nn they would explain you how a large,
complex algebraic expression was evaluated by the BASIC
interpreter in that machine: they used two stacks, one for numbers, the
other for parentheses and operations, and both would be
emptied in RPNfashion.
I do not know for sure, but I think that it's quite
probable that the TI algebraic machines did calculations
internally likewise.
When used not by compilers or internal software but
by persons, RPN has the important advantage that it lets
you see all intermediate results at all stages of the
calculation. The typical algebraic machine will let you
see just the final result, so you'll have no chance to
detect if something was wrong in midprocess.
The only exception to that was the HP71B Calc Mode,
which would show you all intermediate results when
computing any algebraic expression, in real time, and
would let you go backwards a step at a time, recovering,
say, 5*4 from a backstep of 20, for you to try another
number or operation instead.
