aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--readme.md45
1 files changed, 32 insertions, 13 deletions
diff --git a/readme.md b/readme.md
index 451ef67..3e45771 100644
--- a/readme.md
+++ b/readme.md
@@ -2,7 +2,7 @@
This project proposes a file format for programs encoded in binary
lambda calculus. Its main goal is minimal redundancy and therefore
-allowing maximal optimzation.
+allowing maximal optimization.
It’s kind of inspired by ELF.
@@ -16,17 +16,15 @@ end.
| from | to | content |
|:-----|:-----|:-------------------|
| 0x00 | 0x04 | identifier: “BLoC” |
-| 0x04 | 0x?? | entries |
+| 0x04 | 0x06 | number of entries |
+| 0x06 | 0x?? | entries |
| 0x?? | 0x?? | structure |
### Entry
-| from | to | content |
-|:-----|:-----|:----------------------------------|
-| 0x00 | 0x02 | length of BLC expression in bytes |
-| 0x02 | 0x?? | bit-encoded BLC expression |
-
-The final entry is represented by an entry size of 0.
+| from | to | content |
+|:-----|:-----|:---------------------------|
+| 0x00 | 0x?? | bit-encoded BLC expression |
### Structure
@@ -34,8 +32,29 @@ This reflects the basic structure of the program and can’t use
variables. Instead, the structure entry uses the following derivation of
normal bit-encoded BLC:
-| prefix | content |
-|:---------|:-----------------------------|
-| 00M | abstraction |
-| 01MN | application |
-| 1<entry> | 2 byte reference to an entry |
+| prefix | content |
+|:-------|:------------------------------|
+| 00M | abstraction of expression `M` |
+| 01MN | application of `M` and `N` |
+| 1I | 2 byte index to an entry |
+
+## Example
+
+Let `E` be some kind of expression like `E=\x.(((M (\y.N)) M) N)`, where
+`M` and `N` are both arbitrary expressions of length 16.
+
+The raw BLC expression of `E` would then be `E=00010101M00NMN`. This
+obviously has the drawback of redundant repetition of `M` and `N`.
+
+A possible encoding in BLoC:
+
+| from | to | content |
+|:-----|:-----|:---------------------------------------------------------------------------|
+| 0x00 | 0x04 | “BLoC” |
+| 0x04 | 0x06 | number of entries: 2 |
+| 0x06 | 0x16 | `M` in BLC |
+| 0x16 | 0x26 | `N` in BLC |
+| 0x26 | 0x32 | `000101011<M>001<N>1<M>1<N>`, where `<M>=0` and `<N>=1` are 2 byte indices |
+
+Even using this small example BLoC uses less space than BLC (0x32 vs.
+0x42 bytes).