4 ms·
Not familiar with WebAssembly, but from the namesake was expecting the syntax to kind of resemble assembly. He is showing S-expressions ? That is its' syntax ?
by rusakov-field 7mo ago
Not familiar with WebAssembly, but from the namesake was expecting the syntax to kind of resemble assembly.
He is showing S-expressions ? That is its' syntax ? I am intrigued now.
- flohofwoe 7mo agoReal-world WAT (WASM text format) looks more like this (e.g. it looks like a 'structured assembly' type of thing): i32.const 27512 i32.load local.tee $var1 if i32.const 27404 i32.load local.get $var1 call_indirect (param i32) end S-expressions are only used outside such instruction blocks for the 'program-structure' (e.g. see: https://developer.mozilla.org/en-US/docs/WebAssembly/Reference/Variables/local https://developer.mozilla.org/en-US/docs/WebAssembly/Referen...). IIRC early pre-release-versions of WASM were entirely built from S-expressions and as a 'pure stack machine' (I may remember wrong though). To see what a complete WASM blob looks like in WAT format you can go here: https://floooh.github.io/sokol-html5/clear-sapp.html https://floooh.github.io/sokol-html5/clear-sapp.html, open the browser devtools, go to the 'Sources' tab and click the `clear-sapp.wasm` file).
- tlively 7mo agoThis is partially true, but the standard text format also allows the instructions to be nested as S-expressions, for example: (i32.add (i32.const 0) (i32.const 1)) Many projects, including the official spec test suite and the Binaryen test suite, primarily use this format. > IIRC early pre-release-versions of WASM were entirely built from S-expressions and as a 'pure stack machine' (I may remember wrong though). Yes, the S-expressions predate WebAssembly even being a stack machine. Originally the design was that it encoded an AST, so the folded S-expression format was the only option. There was a lot of discussion back in the day (before my time) about creating a better text format, but no one could agree on what it should be, so they just defaulted to the S-expression idea and focused on getting WebAssembly out the door.