articles/forth.md: update
This commit is contained in:
parent
44ef71c658
commit
765b8db461
1 changed files with 5 additions and 6 deletions
|
@ -24,13 +24,12 @@ is applied:
|
|||
## User defined words
|
||||
The programmer can of course define his own words, in Forth this is called "compiling":
|
||||
```forth
|
||||
: \ the `:` word starts compilation
|
||||
sq \ name of our word
|
||||
dup \ DUPplicate the value at the top of the stack
|
||||
* \ multiply
|
||||
; \ `;` ends compilation mode
|
||||
: sq \ `:` starts compilation, followed immediately by the name of our word
|
||||
dup \ DUPplicate the value at the top of the stack
|
||||
* \ multiply
|
||||
; \ `;` ends compilation mode
|
||||
|
||||
8 sq . \ ==> 64
|
||||
8 sq . \ ==> 64
|
||||
```
|
||||
When compilation mode is entered (with `:`), the Forth environment reads the next word, which becomes
|
||||
the name of our defined word (in this case `sq`) and after that it appends the addresses of all words
|
||||
|
|
Loading…
Add table
Reference in a new issue