News for hackers. Stuff that matters.
Re:Stack-Oriented Programming by olooney on Tuesday January 14, 2020 @04:07PM (#22049261)
For a stack oriented language, postfix is execution order. Consider the program "2 3 +". This is really three instructions:

1. Push the literal 2 onto the stack

2. Push the literal 3 onto the stack

3. Execute the Plus Operation

Therefore, there is no need to use a compiler, or even Dijkstra's shunting-yard algorithm[1], to reorder the statements for execution. This makes it extremely easy to write a compiler or interpreter for a stack-oriented language with postfix syntax: you never have to do any parsing at all, you just execute (or emit byte code) for each token as it comes, never needing to look forwards or backwards even a single token.

[1]: https://en.wikipedia.org/wiki/Shunting-yard_algorithm

There are no comments on this comment yet.