Paste: book example
Plain Text |
|Date: ||Thu, 15 Dec 2011 08:15:04|
moral: every value goes into the datastack.
the datastack is usually called "the stack".
1 will sit there until something is done to it.
stack: 1 2
moral: the stack is like a real-world stack: cumulative.
the stack can hold many items.
the rightmost item is the top of the stack.
"top of stack" is commonly shortened to TOS.
TOS also means "the item on the top of the stack".
moral: + is a function that takes two numbers, adds them up and places the result on the stack.
functions in Factor are called "words", and libraries are "vocabularies" (short: vocabs)
ordinary words expect their arguments on the stack.
the + word takes 2 items from the stack and returns 1 item on the stack.