A very small self-hosting supercombinator compiler. pesco 2013 README ========== It is the apocalypse and all your bunker has is a PDP-11. The project is to build a compiler for a modern functional programming language and to get it self-hosting as quickly as possible, bootstrapping from minimal dependencies. To minimize the amount of work in reimplementing the compiler in its own language, the initial iteration (tagged 0.1) is to be cut down as far as possible without compromising expressiveness. Guideline: Implement only language features with *low* cost and *high* utility. The bootstrap compiler is written in less than 500 significant lines of standard C. Features and restrictions: - Haskell-like syntax. - First-class, higher-order functions. - Lazy evaluation. - Monadic I/O. - Compiles to standard C. - Top-level definitions only. - No lambda abstraction. The user must lift manually. - No data types. Scott encoding is used for everything. - No infix operators. - No overloading or type classes. - No type or other checks after parsing. - Missing functions and variables are reported by the C compiler. - Type mismatches typically cause silent failure or infinite loops. - No module system or include mechanism. Influences: - Haskell http://www.haskell.org/ - GRIN http://mirror.seize.it/papers/ - Idris http://www.idris-lang.org/ - SICP http://mitpress.mit.edu/sicp/full-text/book/book.html WIP home: http://khjk.org/~pesco/goaway/ History ----------- 0.2 - simple mark-and-sweep garbage-collector functioning - run-time system split out into common C source prefix 0.1 - bootstrap compiler seems stable, suitable for trivial programs - larger programs (like the compiler) will exhaust memory quickly - start of mark-and-sweep garbage collector (disabled) 0.1b1 - bootstrap compiler changed to lazy evaluation - self-hosting compiler is coming along 0.1b - more bootstrap compiler tests - start of self-hosting compiler in progress 0.1a - bootstrap compiler using eager evaluation works and passes a bunch of tests Version numbers ------------------- Version numbering policy is adopted directly from Tcl, copied with only slight adaptation in formatting and wording from the 'package(3tcl)' manpage. Version numbers consist of one or more decimal numbers separated by dots, such as 2 or 1.162 or 3.1.13.1. The first number is called the major version number. Larger numbers correspond to later versions, with leftmost numbers having greater significance. For example, version 2.1 is later than 1.3 and version 3.4.6 is later than 3.3.5. Missing fields are equivalent to zeroes: version 1.3 is the same as version 1.3.0 and 1.3.0.0, so it is earlier than 1.3.1 or 1.3.0.2. In addition, the letters “a” (alpha) or “b” (beta) may appear exactly once to replace a dot for separation. These letters semantically add a negative specifier into the version, where “a” is -2, and “b” is -1. Each may be specified only once, and “a” or “b” are mutually exclusive. Thus 1.3a1 becomes (semantically) 1.3.-2.1, 1.3b1 is 1.3.-1.1. Negative numbers are not directly allowed in version specifiers. A version number not containing the letters “a” or “b” as specified above is called a stable version, whereas presence of the letters causes the version to be called is unstable. A later version is assumed to be backward compatible with an earlier version as long as both have the same major version number. For example, programs written for version 2.3 of a package should work unchanged under versions 2.3.2, 2.4, and 2.5.1. Changes in the major version number signify incompatible changes: if code is written to use version 2.1 of a package, it is not guaranteed to work unmodified with either version 1.7.3 or version 3.1.