-
Notifications
You must be signed in to change notification settings - Fork 0
/
WORD-HIDING.4TH
51 lines (41 loc) · 1.18 KB
/
WORD-HIDING.4TH
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
( *WIP* - CRASH
( simple namespaces [?] by hiding parts of vocabulary
( - a primitive alternative to dictionaries
( Fig-Forth / APX Forth for Atari 8-bit
: ['] [COMPILE] ' ;
: AA ." I am A! " ;
: BB ." I am B! " AA ;
: CC ." I am C! " BB AA ;
( CRASH FIXME )
( UNCLEAR HOW TO PREPARE AND UPDATE SLOT )
: ::NS ( hide a series of earlier words )
0 IF 99 THEN ( LFA "memory slot", init to 99 )
' AA LFA @ ( first word to hide is AA = ( n1 )
( ['] LFA @ ( TODO: custom word to hide from )
[ SMUDGE ] ' ::NS
[ SMUDGE ] ( own PFA ( n2 )
2DUP ( n1 n2 n1 n2 )
2+ 2+ 2+ ! ( LFA to "slot" )
LFA ! ; ( ::NS behind AA )
( CRASH FIXME )
: ENDS:: ( restore the link using LFA memory in ::NS ) ( -- )
['] DUP DUP DUP ( n n n n )
IF ( only if LFA memory <> 0 ) ( n n n )
LFA ! ( restore link ) ( n )
99 SWAP ! ( put 99 back into the LFA memory )
ELSE DROP DROP DROP THEN ( - ) ;
AA BB CC ( OK )
VLIST
::NS
AA ( error )
CC ( error )
ENDS:: ::NS ( CRASH FIXME )
AA BB CC ( OK )
;S
( helper / check )
' C LFA @ 11014 ?PAIRS
' B NFA 11014 ?PAIRS
' B LFA @ 11006 ?PAIRS
' A NFA 11006 ?PAIRS
' A LFA @ 10970 ?PAIRS
' ASCII NFA 10970 ?PAIRS