RoyalIcing / Orb

Write WebAssembly with Elixir
https://useorb.dev
BSD 3-Clause "New" or "Revised" License
198 stars 1 forks source link

Allow destructuring from tuples? #32

Open RoyalIcing opened 3 months ago

RoyalIcing commented 3 months ago

Now we can return tuples #20 we might want to use tuples for other operations such as assignment.

We could allow someone to write:

  defw example(), I32, a: I32, b: I32 do
    {a, b} = func_returning_two_i32s()
    a + b
  end

You can’t have a local in WebAssembly be backed by more than a primitive (you can’t have local a be {i32, i32}), so that prevents us from writing a = func_returning_two_i32s(). (Unless we added higher-level combo locals on top, which I want to wait and see with Orb 1.0 and how people find writing programs in it).