fix many uses of deprecated names (thanks john_cephalopoda) [first of a few patched related to this]
FossilOrigin-Name: faa0b6ed0fa09b4307285cfc8a6172762636285bb7864e64cff2995e4d9ba324
This commit is contained in:
parent
4b8c651bf2
commit
c676b83793
8 changed files with 18 additions and 17 deletions
|
@ -16,7 +16,7 @@ and traditional Forth.
|
||||||
| Conditionals #2 | `NOT IF 1 THEN` | `[ #1 ] -if` |
|
| Conditionals #2 | `NOT IF 1 THEN` | `[ #1 ] -if` |
|
||||||
| Conditionals #3 | `IF 1 ELSE 2 THEN` | `[ #1 ] [ #2 ] choose` |
|
| Conditionals #3 | `IF 1 ELSE 2 THEN` | `[ #1 ] [ #2 ] choose` |
|
||||||
| Counted Loops | `10 0 DO LOOP` | `#10 [ ] times` |
|
| Counted Loops | `10 0 DO LOOP` | `#10 [ ] times` |
|
||||||
| Counted Loops w/Index | `10 0 DO I LOOP` | `#10 [ I ] times<with-index>` |
|
| Counted Loops w/Index | `10 0 DO I LOOP` | `#10 [ I ] indexed-times` |
|
||||||
| Unconditional Loops | `BEGIN AGAIN` | `repeat again` |
|
| Unconditional Loops | `BEGIN AGAIN` | `repeat again` |
|
||||||
| Return Stack | `10 >R ... R>` | `#10 push ... pop` |
|
| Return Stack | `10 >R ... R>` | `#10 push ... pop` |
|
||||||
|
|
||||||
|
|
|
@ -5,14 +5,14 @@ static global environment.* This can be difficult to explain, so let's
|
||||||
take a quick look at how it works:
|
take a quick look at how it works:
|
||||||
|
|
||||||
~~~
|
~~~
|
||||||
#1000 'a var<n>
|
#1000 'a var-n
|
||||||
:scale (x-y) @a * ;
|
:scale (x-y) @a * ;
|
||||||
#3 scale n:put
|
#3 scale n:put
|
||||||
>>> 3000
|
>>> 3000
|
||||||
#100 !a
|
#100 !a
|
||||||
#3 scale n:put
|
#3 scale n:put
|
||||||
>>> 300
|
>>> 300
|
||||||
#5 'a var<n>
|
#5 'a var-n
|
||||||
#3 scale n:put
|
#3 scale n:put
|
||||||
>>> 300
|
>>> 300
|
||||||
@a n:put
|
@a n:put
|
||||||
|
|
|
@ -39,19 +39,19 @@ when to stop running.
|
||||||
## Counted Loops
|
## Counted Loops
|
||||||
|
|
||||||
There are two combinators for counted loops. These are `times` and
|
There are two combinators for counted loops. These are `times` and
|
||||||
`times<with-index>`.
|
`indexed-times`.
|
||||||
|
|
||||||
#0 #10 [ dup n:put sp n:inc ] times nl
|
#0 #10 [ dup n:put sp n:inc ] times nl
|
||||||
#10 [ I n:put sp ] times<with-index>
|
#10 [ I n:put sp ] indexed-times
|
||||||
|
|
||||||
The `times<with-index>` provides an index via the `I`, `J`, and
|
The `indexed-times` provides an index via the `I`, `J`, and
|
||||||
`K` words. `I` will be the index of the current loop, with `J` and
|
`K` words. `I` will be the index of the current loop, with `J` and
|
||||||
`K` being the indexes of the next two older loops.
|
`K` being the indexes of the next two older loops.
|
||||||
|
|
||||||
The loop indexes can be accessed outside the loop body:
|
The loop indexes can be accessed outside the loop body:
|
||||||
|
|
||||||
:display I n:square n:put sp ;
|
:display I n:square n:put sp ;
|
||||||
:squares [ display ] times<with-index> nl ;
|
:squares [ display ] indexed-times nl ;
|
||||||
#100 squares
|
#100 squares
|
||||||
|
|
||||||
## Tradeoffs
|
## Tradeoffs
|
||||||
|
@ -59,5 +59,5 @@ The loop indexes can be accessed outside the loop body:
|
||||||
The unconditional loop form is more efficient as it's just a
|
The unconditional loop form is more efficient as it's just a
|
||||||
simple jump operation. The `times` counted loops are a little
|
simple jump operation. The `times` counted loops are a little
|
||||||
slower, but can be cleaner and more readable in many cases. The
|
slower, but can be cleaner and more readable in many cases. The
|
||||||
`times<with-index>` form is significantly slower than the other
|
`indexed-times` form is significantly slower than the other
|
||||||
two forms.
|
two forms.
|
||||||
|
|
|
@ -121,12 +121,12 @@ to the stack.
|
||||||
#1 #10 [ dup n:put sp n:inc ] times drop
|
#1 #10 [ dup n:put sp n:inc ] times drop
|
||||||
```
|
```
|
||||||
|
|
||||||
There is also a `times<with-index>` variation that provides
|
There is also a `indexed-times` variation that provides
|
||||||
access to the loop index (via `I`) and parent loop indexes
|
access to the loop index (via `I`) and parent loop indexes
|
||||||
(via `J` and `K`).
|
(via `J` and `K`).
|
||||||
|
|
||||||
```
|
```
|
||||||
#10 [ I n:put sp ] times<with-index>
|
#10 [ I n:put sp ] indexed-times
|
||||||
```
|
```
|
||||||
|
|
||||||
## Data Flow
|
## Data Flow
|
||||||
|
|
|
@ -184,7 +184,7 @@ It should be pretty straightforward though.
|
||||||
| pos | 'Stack:_ s:put dump-stack ;
|
| pos | 'Stack:_ s:put dump-stack ;
|
||||||
:format | call | nl ;
|
:format | call | nl ;
|
||||||
:line [ #64 [ fetch-next c:put ] times ] format ;
|
:line [ #64 [ fetch-next c:put ] times ] format ;
|
||||||
:code &Block #16 [ line ] times<with-index> drop ;
|
:code &Block #16 [ line ] indexed-times drop ;
|
||||||
:tob &TOB #4 [ line ] times drop ;
|
:tob &TOB #4 [ line ] times drop ;
|
||||||
---reveal---
|
---reveal---
|
||||||
:block:display (-) hook
|
:block:display (-) hook
|
||||||
|
@ -366,7 +366,7 @@ These are helpful to quickly navigate through a block.
|
||||||
## Code Sharing
|
## Code Sharing
|
||||||
|
|
||||||
~~~
|
~~~
|
||||||
TRUE 'UseSprunge var<n>
|
TRUE 'UseSprunge var-n
|
||||||
|
|
||||||
{{
|
{{
|
||||||
'/home/crc/public 'PASTEBIN-PATH s:const
|
'/home/crc/public 'PASTEBIN-PATH s:const
|
||||||
|
@ -376,8 +376,8 @@ TRUE 'UseSprunge var<n>
|
||||||
:c:put<file> @FID file:write ;
|
:c:put<file> @FID file:write ;
|
||||||
:line# I dup #10 lt? &sp if n:put ':_ s:put ;
|
:line# I dup #10 lt? &sp if n:put ':_ s:put ;
|
||||||
:line line# #64 [ fetch-next c:put ] times nl ;
|
:line line# #64 [ fetch-next c:put ] times nl ;
|
||||||
:generate &Block #16 [ line ] times<with-index> drop ;
|
:generate &Block #16 [ line ] indexed-times drop ;
|
||||||
:export TEMPFILE file:open<for-writing> !FID
|
:export TEMPFILE file:open-for-writing !FID
|
||||||
&c:put<file> &c:put set-hook generate
|
&c:put<file> &c:put set-hook generate
|
||||||
&c:put unhook @FID file:close ;
|
&c:put unhook @FID file:close ;
|
||||||
'MD5 var
|
'MD5 var
|
||||||
|
|
|
@ -11,7 +11,8 @@ It's intentionally kept minimal, handling only text files and directories. The i
|
||||||
There is also a `Results` variable which will point to the data set being displayed.
|
There is also a `Results` variable which will point to the data set being displayed.
|
||||||
|
|
||||||
~~~
|
~~~
|
||||||
#34 'WrapPoint var<n>
|
#34 'WrapPoint var-n
|
||||||
|
|
||||||
'Results var
|
'Results var
|
||||||
'TARGET d:create #1024 #64 * allot
|
'TARGET d:create #1024 #64 * allot
|
||||||
~~~
|
~~~
|
||||||
|
|
|
@ -85,7 +85,7 @@ Then variables.
|
||||||
|
|
||||||
~~~
|
~~~
|
||||||
:variable?
|
:variable?
|
||||||
dup 'var s:ends-with? over 'var<n> s:ends-with? or ;
|
dup 'var s:ends-with? over 'var-n s:ends-with? or ;
|
||||||
|
|
||||||
:output-name
|
:output-name
|
||||||
ASCII:SPACE s:tokenize dup a:length #2 - a:fetch n:inc s:put ;
|
ASCII:SPACE s:tokenize dup a:length #2 - a:fetch n:inc s:put ;
|
||||||
|
|
|
@ -177,7 +177,7 @@ It should be pretty straightforward though.
|
||||||
:status block# sp pos '_::_ s:put dump-stack ;
|
:status block# sp pos '_::_ s:put dump-stack ;
|
||||||
:format '_|_ s:put call '_| s:put nl ;
|
:format '_|_ s:put call '_| s:put nl ;
|
||||||
:line [ #64 [ fetch-next c:put ] times ] format ;
|
:line [ #64 [ fetch-next c:put ] times ] format ;
|
||||||
:code &Block #16 [ line ] times<with-index> drop ;
|
:code &Block #16 [ line ] indexed-times drop ;
|
||||||
:format '_|_ s:put call '_| s:put nl ;
|
:format '_|_ s:put call '_| s:put nl ;
|
||||||
:tob &TOB #4 [ line ] times drop ;
|
:tob &TOB #4 [ line ] times drop ;
|
||||||
---reveal---
|
---reveal---
|
||||||
|
|
Loading…
Reference in a new issue