-
-
Save cmtptr/780a826a7ea837c0f58d453c22e7b5c6 to your computer and use it in GitHub Desktop.
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
program foo | |
123 constant qwe | |
variable x variable y | |
: part-one blah qwe something x ! ; | |
: part-two blah blah something-else y !; | |
: part-three blah blah x @ y @ * or whatever ; | |
main: part-one part-two part-three ; | |
end-program | |
program bar | |
variable x ( different from foo's x ) | |
: part-one x @ dup 1+ x ! ; ( different from foo's part-one ) | |
( when bar recurses, the inner bar gets its own instance of x, like | |
stack frames in c ) | |
main: part-one 1 and if bar then ; | |
end-program | |
( call foo and bar as words themselves, and they execute with their own private | |
contexts per each invokation ) | |
: baz foo bar ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment