Update 2012/tromp
Format and typo fix README.md. Un-rot13 the how13 and make it how.md. The reversal of rot13 was discussed on GitHub at Landon's request. One link was fixed. Added other links. I was sorely tempted to make two links for garbage collector, garbage == Windows and collector == the actual garbage collector :-) but I decided that that's not my place so I didn't do it as much as I wanted to (and I dearly wanted to!). In some places there probably should be links again but since they were linked to earlier in the document I'm going to pass on it for now. I believe but am not certain that with this commit with the exception of 2012/README.md that 2012 is finished at least with format fixes in README.md files (unless I come across something when trying out the entries later on).
This commit is contained in:
1 parent
87daf5d056
commit
242726870a
3 files changed
+369
-272
No files matched your search
@@ -0,0 +1,66 @@
|
||||
# Spoiler
|
||||
|
||||
The program implements a so called [Krivine
|
||||
machine](https://en.wikipedia.org/wiki/Krivine_machine), enhanced with a [basic
|
||||
input/output system](https://en.wikipedia.org/wiki/BIOS) and a reference
|
||||
counting [garbage collector](https://en.wikipedia.org/wiki/Waste_collector). The
|
||||
Krivine machine is a stepwise transformer of a global state consisting of the
|
||||
current term, the current environment (a list of closures), and a stack of
|
||||
continuations (see the 3rd reference for details).
|
||||
|
||||
The term space holds [lambda
|
||||
calculus](https://en.wikipedia.org/wiki/Lambda_calculus) terms in the following
|
||||
format. 0 denotes some form of IO; the only four occurrences are at:
|
||||
|
||||
```
|
||||
C=13: recognizes end of a byte
|
||||
C=20: recognize output of 0 bit
|
||||
C=21: recognize output of 1 bit
|
||||
C=end: input list, expanded lazily
|
||||
```
|
||||
|
||||
`1` denotes a variable, with next entry its de [Bruijn
|
||||
index](https://en.wikipedia.org/wiki/De_Bruijn_index).
|
||||
|
||||
`2` denotes application with next entry the size of the term being applied.
|
||||
|
||||
`3` denotes lambda abstraction.
|
||||
|
||||
|
||||
A closure consists of the following items:
|
||||
|
||||
0. pointer to the next closure (as part of an environment), or next record on
|
||||
free list.
|
||||
1. reference count
|
||||
2. pointer to environment
|
||||
3. lambda term (index in term space)
|
||||
|
||||
Here's what each variable do:
|
||||
|
||||
```
|
||||
L Lambda term space
|
||||
m mode: 0 for bits and 7 for bytes
|
||||
b bits remaining unread in I, -1 on EOF
|
||||
D Desirable temporary
|
||||
c continuation context
|
||||
a active environment pointer
|
||||
C Current term index
|
||||
U Ultimate term pointer
|
||||
u utility entry
|
||||
B Born to be free-list of closures
|
||||
I Input character
|
||||
O Output character
|
||||
e entry of current term
|
||||
```
|
||||
|
||||
Here's what each of the 6 auxiliary functions do:
|
||||
|
||||
```
|
||||
s variable lookup in active environment with de Bruijn index u
|
||||
S gets one bit of input, setting b to -1 on EOF or to remaining number of bits in current byte
|
||||
k copy fragment from string literal holding lambda terms xor 46 into current end of term space
|
||||
x expand input, adding 11 (resp. 99) entries to term space for bit (resp. byte) mode
|
||||
p parses BLC-encoded lambda term using S(), stores results in term space and returns length
|
||||
d decrease reference counter, add record to free list on reaching zero
|
||||
```
|
||||
|
||||
Reference in new issue
Block a user