-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# ABOUT STACK NOTATION | ||
|
||
__The top of the stack is to the right.__, | ||
Forth 2012, Standart. | ||
|
||
__ OVER ( n1 n2 — n1 n2 n1 ) Copies second item to top__, | ||
"Starting Forth", Leo Brodie | ||
|
||
I have a cognitive problem about stack notation. | ||
|
||
It represents the order of "pushed into the stack", | ||
not the order "count from top of stack". | ||
|
||
In standards 79, 83, 94, the cells in ( after -- before ), | ||
should be arranged on the left as bottom and on the right as top. | ||
|
||
For example, when representing ( w1 w2 w3 -- ), the order | ||
is be w3 at the top and w1 at the bottom. | ||
|
||
The cells indices for | ||
|
||
( w1 w2 w3 -- ), are of w1 is 3 and of w2 is 2, | ||
|
||
but for | ||
|
||
( w1 w2 -- ), are of w1 is 2 and of w2 is 1. | ||
|
||
This is very confusing to me, when using the stack in words. | ||
|
||
I prefer to use w1 always at top, and the following indicating | ||
the position relative to the top of the stack, as the depth level. | ||
|
||
So w1 will always be 1, w2 will always be 2, and so on, | ||
the indices are always in the same order. | ||
|
||
To differentiate, I'm using double parentheses as comments of stack | ||
elements to indicate the top of stack is at left, thus, | ||
it is ever the last element pushed into stack. |