1 2024-09-03
2 data array works. next: push/pop
3
4 2024-09-05
5 push and pop work
6 getting word tokens works
7
8 2024-09-06
9 dictionary name table works
10
11 Problem: I can easily store a token
12 sequence in the directionary. But
13 to make a return stack function
14 correctly, I would need to store
15 both the name *and* position of the
16 last call site?
17
18 Solution?: Instead of storing the
19 token sequences in separate table
20 entries, what if I store all source
21 in the same string and just store
22 pointers to it?
23
24 And if the return stack is empty,
25 we're reading from stdin.
26
27
28 2024-09-10
29
30 Holy cow, this works:
31
32 : 2x DUP + ; 5 2x . CR
33 : 4x 2x 2x ; 5 4x . CR
34
35 Words calling words. So the return stack works.
36 Whew. Definitely had some tough bugs there for
37 a bit, but nothing some "print debugging" can't
38 fix.
39
40 2024-09-11
41
42 Well, now that my initial goal is accomplished,
43 I feel a bit aimless.
44
45 I could just start implementing various words,
46 but that doesn't exactly fill me with joy.
47
48 So I've decided to go get a new goal.
49 I've always liked the 99 Bottles of Beer exercise
50 where you print out the lyrics to the song
51 in your favorite programming language.
52
53 I found a good one and threw it into a 99.forth
54 file.
55
56 Is it weird that it's kind of a relief to see
57 errors so I know what to do next? No, it is not
58 weird.
59
60 $ snobol forth.sno <99.forth
61 ERROR: '(' not in dictionary.
62 ERROR: 'Bottles' not in dictionary.
63 ERROR: 'of' not in dictionary.
64 ERROR: 'Beer' not in dictionary.
65 ...
66
67 Looks like I need to implement "( ... )" comments
68 first.
69
70 This, of course, will cause a whole cascade of
71 other words needing to be defined. But that's the
72 whole idea.
73
74 It looks like the total list of words to implement
75 the traditional bootstrapped functionality needed
76 for 99 Bottles is something like:
77
78 ' ( +LOOP , - -1 . ." 0BRANCH 1- = ?DUP @ BEGIN
79 DO ELSE HERE I IF KEY SWAP THEN UNTIL [CHAR]
80
81 (To get this list, I did a little manual recursive
82 walk through JonesFORTH to get the definitions of
83 the words used in 99 Bottles.)
84
85
86 ' ( +LOOP , - -1 . ." 0BRANCH 1- = ?DUP @ BEGIN
87 DO ELSE HERE I IF KEY SWAP THEN UNTIL [CHAR]
88
89
90 ... Many days later ...
91
92 Went a totally different direction. Not slavishly
93 following traditional implementation of the Forth
94 words. Nope, just making straightforward Snobol
95 functions for what's needed for 99 Bottles.
96
97 ... Aaaaand, DONE ...
98
99 I guess I wasn't very good about keeping up the log
100 but I will have some conclusions about how this
101 went that I'll be writing somewhere.