Could Lisp be used as a programming language for the web as well as desktop and mobile?
WebAssembly is a virtual machine byte code language that can really be run anywhere, even in WebAssembly itself! Lisp is a high-level language that could be useful for many complicated scenarios, like GUIs. What happens if we mix these two systems?
The WebAssembly VM used for the compiler is based on libawsm https://github.com/rolfrm/awsm
The emitted byte code should be conformant with WebAssembly VMs, but WebAssembly does not allow loading or modifying code at runtime. Hence the Lisp compiler will run on a modified WebAssembly engine and will after compilation save the image to a webassemby-conformant format.
- Support a subset of Scheme: For example https://small.r7rs.org
- Host itself
- Deploy a WASM compilant image that can run in a browser.
- GUI Framework for Lisp that runs on any platform, integrating with the native control libraries (HTML, GTK, …).
- Variables
- [Done] Function Arguments
- [Done] Locals
- [Done] Globals
- [Done] Loops
- [Done] Strings
- [25% Done]Symbol Names
- Alloc implementation
- Bitwise
- basic math
- Error handling
- Stack imbalance
- type checks
- [Done ]errors / fault:
- asserts
- Garbage Collection
- Code generation in AWSM Lisp
- FFI - Link with C functions compiled to wasm.
- Macros
- Anonymous functions
- [DONE] defun - Defining functions
- [DONE] conditionals (if)
The type system is inspired by the one used by SBCL. Everything is 64bit variables with a header of 3 bits. Arranged as this:
- 0 - NIL type
- 1 - i64 type
- 2 - f64 type
- 3 - cons type
- 4 - symbol type.
The NIL type covers both nil/truth values. Checking for nil/null is easy. Its just comparing the i64 value with 0. the opposite of nil is ‘t’ which everything else is, but specifically (not nil) is the number 1 with the type ‘nil’.
Any more sophistical type is some kind of cons type. A cons is defined as two i64 values and a single 8 bit type header. For now these are defined: 0 - Regular cons list. 1 - Chunked strings. A string is a cons list with each CAR being 7 bytes of string data and each CDR being the rest of the string. 2 - struct 3 - array