Stack Effect Diagrams
As an aid to understanding the effect of statement, a short comment is used showing the top of the stack before and after the statement. The top of the stack is rightmost if there are multiple items. This notation is commonly used in the Forth language, where comments are enclosed in parentheses.
( before -- after )For example, the basic Forth stack operators are described:
dup ( a -- a a ) drop ( a -- ) swap ( a b -- b a ) over ( a b -- a b a ) rot ( a b c -- b c a )And the fib function below is described:
fib ( n -- fib )It is equivalent to preconditions and postconditions in Hoare's logic. Both comments may also be referenced as assertions, thought not necessarily in context of Stack-based languages.
Read more about this topic: Stack-oriented Programming Language
Famous quotes containing the words stack, effect and/or diagrams:
“What is a farm but a mute gospel? The chaff and the wheat, weeds and plants, blight, rain, insects, sunit is a sacred emblem from the first furrow of spring to the last stack which the snow of winter overtakes in the fields.”
—Ralph Waldo Emerson (18031882)
“No being exists or can exist which is not related to space in some way. God is everywhere, created minds are somewhere, and body is in the space that it occupies; and whatever is neither everywhere nor anywhere does not exist. And hence it follows that space is an effect arising from the first existence of being, because when any being is postulated, space is postulated.”
—Isaac Newton (16421727)
“Professors could silence me then; they had figures, diagrams, maps, books.... I was learning that books and diagrams can be evil things if they deaden the mind of man and make him blind or cynical before subjection of any kind.”
—Agnes Smedley (18901950)