|
|
|
@ -8,7 +8,7 @@ Currently, the language is entirely interactive -- to explore, simply run `go ru |
|
|
|
|
|
|
|
|
|
Prosper is stack-based, as mentioned, so all the standard stack semantics are present: |
|
|
|
|
|
|
|
|
|
``` |
|
|
|
|
```forth |
|
|
|
|
> 1 2 3 4 + * - |
|
|
|
|
ok |
|
|
|
|
> . |
|
|
|
@ -17,7 +17,7 @@ ok |
|
|
|
|
|
|
|
|
|
New words can be defined using `: ;`: |
|
|
|
|
|
|
|
|
|
``` |
|
|
|
|
```forth |
|
|
|
|
> : SQUARE DUP * ; |
|
|
|
|
ok |
|
|
|
|
> 10 SQUARE . |
|
|
|
@ -26,7 +26,7 @@ ok |
|
|
|
|
|
|
|
|
|
It has a single loop construct, `DO LOOP`: |
|
|
|
|
|
|
|
|
|
``` |
|
|
|
|
```forth |
|
|
|
|
> : TOFIVE 5 0 DO I . LOOP ; |
|
|
|
|
ok |
|
|
|
|
> TOFIVE |
|
|
|
@ -35,7 +35,7 @@ ok |
|
|
|
|
|
|
|
|
|
Branches using `IF ELSE THEN` work: |
|
|
|
|
|
|
|
|
|
``` |
|
|
|
|
```forth |
|
|
|
|
> : EMOJI 0 < IF 128201 EMIT ELSE 128200 EMIT THEN ; |
|
|
|
|
ok |
|
|
|
|
> 100 EMOJI |
|
|
|
@ -46,7 +46,7 @@ ok |
|
|
|
|
|
|
|
|
|
Here's a Fibonacci implementation: |
|
|
|
|
|
|
|
|
|
``` |
|
|
|
|
```forth |
|
|
|
|
> : FIB 2DUP + ; |
|
|
|
|
ok |
|
|
|
|
> : FIBN 0 1 ROT 1 DO FIB ROT DROP LOOP SWAP DROP ; |
|
|
|
@ -57,7 +57,7 @@ ok |
|
|
|
|
|
|
|
|
|
Propser also has a basic off-stack memory model using variables, constants, and pointers: |
|
|
|
|
|
|
|
|
|
``` |
|
|
|
|
```forth |
|
|
|
|
> VARIABLE FOO |
|
|
|
|
ok |
|
|
|
|
> 10 FOO ! |
|
|
|
@ -74,7 +74,7 @@ ok |
|
|
|
|
|
|
|
|
|
And, of course, it knows how to quit: |
|
|
|
|
|
|
|
|
|
``` |
|
|
|
|
```forth |
|
|
|
|
> BYE |
|
|
|
|
bye |
|
|
|
|
``` |
|
|
|
|