Stack-oriented Programming Language - Stack Effect Diagrams

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:

    ““Farewell to barn and stack and tree,
    Farewell to Severn shore.
    Terence, look your last at me,
    For I come home no more.”
    —A.E. (Alfred Edward)

    “To get time for civic work, for exercise, for neighborhood projects, reading or meditation, or just plain time to themselves, mothers need to hold out against the fairly recent but surprisingly entrenched myth that “good mothers” are constantly with their children. They will have to speak out at last about the demoralizing effect of spending day after day with small children, no matter how much they love them.”
    —Wendy Coppedge Sanford. Ourselves and Our Children, by Boston Women’s Health Book Collective, introduction (1978)

    “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 (1890–1950)