Update README.md

This commit is contained in:
Attila Magyar 2021-06-19 21:49:40 +02:00 committed by GitHub
parent 03936643a1
commit 52f1372282
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -131,13 +131,27 @@ Control structres are compile time words with no interpretation semantics.
There are two types of locals in FCL. Local constant `->` and local variable `=>`.
`-> name` loads the top of the stack into the local, called `name`.
`-> a` loads the top of the stack into the local, called `a`.
`name` pushes the value of the local.
`a` pushes the value of the local.
`=> name` loads the top of the stack into the local, called `name`.
`=> b` loads the top of the stack into the local variable, called `b`.
`name` pushes the reference of the local. `name @` pushes the value of the local.
`b` pushes the reference of the local. `b @` pushes the value of the local.
The `->` and `=>` words can be used anywhere within a word, including loop bodies and quotations. You can initialize a local (`0 -> a`) within the word or use the data that was supplied on the call site (`-> a`).
```
: count-even ( n -- c )
-> n 0 => count
n 0 do
i 2 /mod -> quotient -> remainder
remainder 0 = if
count inc
then
loop
count @ ;
```
## List