walt
walt copied to clipboard
Destructuring Assignment
Goal
Allow users to use destructuring assignment.
Overview
Destructuring assignment is pretty helpful and should be implemented. Destructured variables should become locals. Destructured variables should not need type annotation as they can be inferred, so that is super useful.
Acceptance Criteria
- [ ]
const [x, y] = arrayObject;
- [ ]
const {x, y} = vectorObject;
- [ ] Type annotations for destructured locals are not necessary
- [ ] Tests
WASM "is" a stack machine, right? Does that mean you can in theory return multiple values by leaving multiple values on the stack, like in Forth and other concatenative languages? Is something like (type (func (param i32) (result i32 i32)))
legal WASM?
Asking out of curiosity of how returning multiple values might be implemented in Walt (not directly applicable to destructuring, but potentially a way of doing "strength reduction" if an optimising pass is ever introduced?)