binast / binjs-ref

Reference implementation for the JavaScript Binary AST format
https://binast.github.io/binjs-ref/binjs/index.html
Other
431 stars 38 forks source link

In Context 0.2, consider switching between multiple tables #452

Open dominiccooney opened 5 years ago

dominiccooney commented 5 years ago

The "context 0.1" file format has one model for a given field.

Say you have a file where someone's pasted two source files together and the first half of the file uses "var" and the second half uses "let" and "const." In context 0.1 you'll end up with a model with a mixture of var, let and const and need 1-2 bits for each symbol to describe variable kinds.

If instead the file format could have multiple models and switch between them, then for the first half of the file it could have a model specifying 0-bits for "var" and then a switch and a model with 1 bit for "let" or "const", and that would be good.

There are probably fancier ideas where you switch sets of related models at once.

Brotli does something like this, if you look at RFC7932 and the Block-Switch stuff.