Clojure-flavored WASM text format
github.com
github.com
>We have an optimizing compiler for spreadsheets
What is even a compiler for spreadsheets? In spreadsheets you still have an AST, or is it a different structure? Is there any fundamental property of spreadsheet code that enables specific optimizations?
You need to figure out how and when to merge expressions, when it's worth it to extract a loop where the same expression needs to be compiled as two or three variants, because there are invariants between all but two or three of the invocations. You also must decide which collections you want to create out of the reference soup, when you can alias/discard collections and values, how to hoist predicates (for IF and SWITCH), when you can avoid type coercion. For small workbooks, just using tagged unions in a 2D array, plus a string pool, will suffice, but our sheets are so big that we can't afford that.
Been poking a bit here and there at a wasm binary parser and know in that format they're supposed be in order (with custom sections sprinkled wherever) but can't recall seeing anything about the text format order.
But it's not a Clojure->WASM transpiler/compiler, but Clojure-like->WASM transpiler/compiler, as only a subset of Clojure has been implemented and it's not compiling the standard library of Clojure into WASM.
You might be able to find something more lightweight over here though: https://github.com/xtuc/webassemblyjs but I didn't find what you were looking for (but just did a quick look)
Would it be hard to add macros?