-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathREADME
57 lines (39 loc) · 1.56 KB
/
README
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
49
50
51
52
53
54
55
56
57
forego - A Forth implementation in Go
=====================================
Why?
----
For ego. This is me learning the language. Both of them.
Someone once said that everybody who learns Forth and likes it
thinks "oh nice, that'd be cool to write a Forth VM". This
happened to me, but I had no actual reason to do it until I
started searching for a Go learning project.
And?
----
Lessons learned: writing a VM without performance constrains or
a crude assembler is easy, wrapping your head around multiple
run times of Forth compiling words is less so.
So What Is It?
--------------
Forego is a naive implementation of a Forth virtual machine in Go
that I hacked up in a month or so. Here are its main features
and misfeatures:
The Good:
- The compiler, assembler, parser, main loop and disassembler are
now written in Forth. It has (my understanding of) the full
CORE wordset and then some, like:
.( .r u.r :noname compile, parse parse-name refill source-id
to value within \
pick roll ?do again case endcase of endof
.s ? dump words ;code ahead bye state
/string cmove cmove> sliteral
...and those are written in Forth. Type "words" at the prompt
to see the whole list.
The Ambiguous:
- It has no file support and no interaction with the outside
world except key and emit, so untrusted code will have to
overflow a buffer in xterm or something to exploit your box.
The Bad:
- The VM does not resemble real hardware at all.
- The "kernel" ("machine" code) is hardcoded in the package.
- It's probably damn slow.
- The README is incomplete.