The Museum of HP Calculators

HP Forum Archive 17

[ Return to Index | Top of Index ]

Communicating stack state transitions, a notation.
Message #1 Posted by Arne Halvorsen (Norway) on 9 Oct 2007, 4:12 p.m.

I will try using the following notation to communicate RPN program's effect on the stack and LASTX register:

[d,c,b,a][e]->oper. desc.->[d',c',b',a'][e']

The first array with four elements represents the stack where d and d' refers to content of the T stack register and a and a' to content in the X stack register. The e and e' in the single element array refers to the LASTX register's content. Ofcourse actual letters or words used may be choosen to so fit the input/output for particular program.

So for example to describe sqrt:

[d,c,b,v][e]->sqrt->[d,c,b,sqrt(v)][v]

and addition:

[d,c,b,a][e]->+->[d,d,c,b+a][a]

Ofcourse there are other (better?) ways using tables or some kind of bar diagram but think this may work and have the advantage of being easy and fast to type in text only documents.

Anyone of your long time rpn hackers having an opinion on this topic?

      
Re: Communicating stack state transitions, a notation.
Message #2 Posted by Valentin Albillo on 9 Oct 2007, 5:17 p.m.,
in response to message #1 by Arne Halvorsen (Norway)

Hi, Arne:

Obviously it would be far easier on the eyes and more useful if you would use X, Y, Z, T and L instead of a, b, c, d and e, like this:

[X, Y, Z, T | L] -> Sqrt -> [Sqrt(X), Y, Z, T | X ]

or a variation thereof.

Best regards from V.

Edited: 9 Oct 2007, 6:17 p.m. after one or more responses were posted

            
Re: Communicating stack state transitions, a notation.
Message #3 Posted by Arne Halvorsen (Norway) on 9 Oct 2007, 6:16 p.m.,
in response to message #2 by Valentin Albillo

Small details, but think your way of | replacement for my 'two array' notation looks better, will use.

As for the actual letters, think may become confusing if variable bound to orginal position in register; there may be a chain of operation... And if x contains speed of light; use c.

Now, for me LEFT maps to TOP (i.e. T) and I always think of LASTX as 'below' X register... Interesting that you turned it around! Perhaps most people find yours more natural, perhaps its because I am lefthanded :-).

Hmmm, actual that is perhaps more readable... must think about it... to bad there aint enough people interested in this detail to have a poll!

Thanks!

Edited: 9 Oct 2007, 6:17 p.m.

                  
Re: Communicating stack state transitions, a notation.
Message #4 Posted by Walter B on 10 Oct 2007, 2:44 a.m.,
in response to message #3 by Arne Halvorsen (Norway)

God dag Arne,

I like Valentin's notation better because the x-level -- which will change most frequently -- appears leftmost, i.e. first for people reading from left to right.

Just my 20 milli-Euro

                        
Re: Communicating stack state transitions, a notation.
Message #5 Posted by JoseL on 10 Oct 2007, 3:18 a.m.,
in response to message #4 by Walter B

Hi Arne,

I agree with Valentin and Walter.

It's the notation I have been using since my first steps in RPN.

Best regards

                        
Re: Communicating stack state transitions, a notation.
Message #6 Posted by Arne Halvorsen (Norway) on 10 Oct 2007, 3:19 a.m.,
in response to message #4 by Walter B

I have arrived at the same conclusion myself... Good thing I asked :-)

      
Re: Communicating stack state transitions, a notation.
Message #7 Posted by Chris McCormack on 10 Oct 2007, 1:26 p.m.,
in response to message #1 by Arne Halvorsen (Norway)

I would advocate following the stack notation practices used with the programming language Forth. The lowest items on the stack appear to the right, only the applicable levels appear, and two dashes separate the 'before' and 'after' snapshots.


For example:

( y x -- y+x )
would be a compact representation for the '+' key.
If you want to explicitly show the entire stack (and Last X register) this could become
( t z y x | a -- t t z y+x | x ) 

Usually the stack comments would try to convey a little more meaning, such as:
( Lat1 Lon1 Lat2 Lon2 -- Bearing )

to document that calculates the initial great circle bearing to fly from point 1 to point 2.

            
Re: Communicating stack state transitions, a notation.
Message #8 Posted by Arne Halvorsen (Norway) on 10 Oct 2007, 1:43 p.m.,
in response to message #7 by Chris McCormack

Interesting, I remember in my young days there was a lot of talk about the FORTH language... The notation is good and very similar to Valentin's proposal I have addopted (good I did not go ahead with my orginal syntax). I do agree names should reflect nature of value. I use X, Y, Z, T, L for the 'bystanders'...


[ Return to Index | Top of Index ]

Go back to the main exhibit hall