<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="110580" data-post-id="110580">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="OvermindDL1" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/OvermindDL1/120/2677_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  OvermindDL1
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Yep, being able to read/write that entire memory state, especially if it contains the IP, should be quite good.  <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="110580" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/waspvm-run-webassembly-in-elixir/19129/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-110580" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="110580"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="112930" data-post-id="112930">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="alexdovzhanyn" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/alexdovzhanyn/120/15369_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  alexdovzhanyn
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Just released v0.8.1, where this feature and others were added. Here’s a fun blog post on <a href="https://medium.com/@elixiumnetwork/using-waspvm-to-create-a-simple-tic-tac-toe-game-a993ca9d6289" rel="noopener nofollow ugc">using the new Memory API within a WebAssembly tic tac toe game</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="112930" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/waspvm-run-webassembly-in-elixir/19129/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-112930" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="112930"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="113000" data-post-id="113000">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="OvermindDL1" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/OvermindDL1/120/2677_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  OvermindDL1
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><code>board = WaspVM.HostFunction.API.get_memory(ctx, "game_mem", 0, 9)</code>  Oooo awesome!</p>
<p>I like the post, easy to read, follow, and understand.  <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<p>As for <code>WaspVM.HostFunction.API.get_memory/4</code> does that include the instruction pointer and all as well?  I.E. if WASM calls ‘into’ an elixir function, can that elixir function serialize up the whole state then pick up again where it left off (assuming no other elixir functions are on the wasm stack, and probably some argument indicating whether it was just loaded or not)?</p>
<blockquote>
<p>This variable is defined by the  <code>defhost</code>  macro, and is solely used as a reference that’s passed into the HostFunction API.</p>
</blockquote>
<p>As for this, I’m really not a fan of magic variables, why not have the user prepend it to all <code>defhost</code> argument lists so it is explicitly passed in, thus:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defhost get_move_for_player(player) do

defhost draw_board do ... end
</code></pre>
<p>And so forth should actually be written like:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defhost get_move_for_player(vmctx, player) do

defhost draw_board(vmctx) do ... end
</code></pre>
<p>I always try to remember the Python tenant:  <code>Explicit is Better than Implicit</code>  <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<p>Also, does this mean you can’t call the function from outside the WaspVM interpreter?  Like what would you pass in then, the PID like this?</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def run_game do
  # Start a fresh VM instance
  {:ok, pid} = WaspVM.start()
  WaspVM.load_file(pid, "priv/wasm/tic_tac_toe.wasm", imports)
  {:ok, gas, result} = WaspVM.execute(pid, "play")
  WaspVM.HostFunction.API.get_memory(pid, "game_mem", 0, 9)
end
</code></pre>
<p>Also, the calls return the <code>gas</code>, but is there a way to set a limit on how much <code>gas</code> is allowed to be used in a call before it just exceptions out or serializes/pauses its state or so for later resumption?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="113000" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/waspvm-run-webassembly-in-elixir/19129/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-113000" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="113000"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="113080" data-post-id="113080">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="alexdovzhanyn" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/alexdovzhanyn/120/15369_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  alexdovzhanyn
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="OvermindDL1" data-post="14" data-topic="19129">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/overminddl1/48/2677_2.png" class="avatar"> OvermindDL1:</div>
<blockquote>
<p>I like the post, easy to read, follow, and understand. <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
</blockquote>
</aside>
<p>Thanks! Appreciate the feedback tons <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<aside class="quote no-group" data-username="OvermindDL1" data-post="14" data-topic="19129">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/overminddl1/48/2677_2.png" class="avatar"> OvermindDL1:</div>
<blockquote>
<p>does that include the instruction pointer and all as well?</p>
</blockquote>
</aside>
<p>We’ve decided not to expose internal VM state at all – so instruction pointers won’t be available. Things can easily get messy when allowing people to poke around inside the VM – and it should be possible to do most things by serializing / deserializing memory. If we were to expose instruction pointers and the call stack this would be akin to the BEAM providing functionality to do the same at runtime – although useful in some cases, potentially easily destructive.</p>
<aside class="quote no-group" data-username="OvermindDL1" data-post="14" data-topic="19129">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/overminddl1/48/2677_2.png" class="avatar"> OvermindDL1:</div>
<blockquote>
<p>I.E. if WASM calls ‘into’ an elixir function, can that elixir function serialize up the whole state then pick up again where it left off</p>
</blockquote>
</aside>
<p>This allows for messy programming – and is also something that falls outside of the WebAssembly spec. For example: if you have an elixir program that can run and do some work, and then could be stopped, serialized, and restarted by passing state back to the BEAM, certain safety checks such as if the program is in the middle of writing to a file would be bypassed (e.g. it’s dangerous to resume the execution of a function halfway through).</p>
<aside class="quote no-group" data-username="OvermindDL1" data-post="14" data-topic="19129">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/overminddl1/48/2677_2.png" class="avatar"> OvermindDL1:</div>
<blockquote>
<p>I’m really not a fan of magic variables, why not have the user prepend it to all <code>defhost</code> argument lists so it is explicitly passed in</p>
</blockquote>
</aside>
<p>In most cases, I agree that magic variables aren’t the way to go, <em>however</em> in this case I feel as though it makes sense – host function heads defined by <code>defhost</code> need to strictly resemble the function heads that they’ll be exposed as in the WebAssembly module. It could easily get confusing when you have a function like</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defhost get_move_for_player(vmctx. player) do ... end
</code></pre>
<p>that you need to interface with in WebAssembly like</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">(import "Module" "get_move_for_player" (func (param i32) (result i32)))
</code></pre>
<p>because the former has 2 params and the latter has only 1. <a href="https://hexdocs.pm/plug/Plug.Router.html#module-routes" rel="noopener nofollow ugc">Plug does the same thing with their conn variable in the router</a>.</p>
<aside class="quote no-group" data-username="OvermindDL1" data-post="14" data-topic="19129">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/overminddl1/48/2677_2.png" class="avatar"> OvermindDL1:</div>
<blockquote>
<p>Also, does this mean you can’t call the function from outside the WaspVM interpreter? Like what would you pass in then, the PID like this?</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def run_game do
  # Start a fresh VM instance
  {:ok, pid} = WaspVM.start()
  WaspVM.load_file(pid, "priv/wasm/tic_tac_toe.wasm", imports)
  {:ok, gas, result} = WaspVM.execute(pid, "play")
  WaspVM.HostFunction.API.get_memory(pid, "game_mem", 0, 9)
end
</code></pre>
</blockquote>
</aside>
<p>You can! The only thing is that you would need to use the functions defined in the VM itself <a href="https://hexdocs.pm/wasp_vm/WaspVM.html#get_memory/2" rel="noopener nofollow ugc">WaspVM.get_memory/2</a> and <a href="https://hexdocs.pm/wasp_vm/WaspVM.html#update_memory/3" rel="noopener nofollow ugc">WaspVM.update_memory/3</a>, as it takes a reference to the VM directly, and then you can use WaspVM.Memory to interface with the memory. So the above code would be rewritten as</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def run_game do
  # Start a fresh VM instance
  {:ok, pid} = WaspVM.start()
  WaspVM.load_file(pid, "priv/wasm/tic_tac_toe.wasm", imports)
  {:ok, gas, result} = WaspVM.execute(pid, "play")

  # Retrieve an exported memory from the VM
  mem = WaspVM.get_memory(pid, "game_mem")

  # Read bytes from memory
  WaspVM.Memory.get_at(mem, 0, 9)
end
</code></pre>
<aside class="quote no-group" data-username="OvermindDL1" data-post="14" data-topic="19129">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/overminddl1/48/2677_2.png" class="avatar"> OvermindDL1:</div>
<blockquote>
<p>Also, the calls return the <code>gas</code> , but is there a way to set a limit on how much <code>gas</code> is allowed to be used in a call</p>
</blockquote>
</aside>
<p>Yep! you can do this by passing a <code>gas_limit</code> when calling <code>WaspVM.execute</code>:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">WaspVM.execute(pid, "some_func", [], gas_limit: 100)
</code></pre>
<p>If the gas limit is reached, the program will interrupt and return an error.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="113080" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/waspvm-run-webassembly-in-elixir/19129/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-113080" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="113080"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #14"></div>
  </section>
</div>
    <div class="postbit" id="113146" data-post-id="113146">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="OvermindDL1" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/OvermindDL1/120/2677_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  OvermindDL1
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="alexdovzhanyn" data-post="15" data-topic="19129">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/alexdovzhanyn/48/15369_2.png" class="avatar"> alexdovzhanyn:</div>
<blockquote>
<p>In most cases, I agree that magic variables aren’t the way to go, <em>however</em> in this case I feel as though it makes sense – host function heads defined by <code>defhost</code> need to strictly resemble the function heads that they’ll be exposed as in the WebAssembly module. It could easily get confusing when you have a function like</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">
</code></pre>
</blockquote>
</aside>
<p>Then what about adding it as an argument to the <code>defhost</code>?  Like via:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defhost get_move_for_player(player), context: ctx do
  ...
end
</code></pre>
<p>That will just be a <code>defhost</code> definition like:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmacro defhost(head, mappers \\ [], [do: body]) do
  context_var = mappers[:context] || Macro.var(:ctx, nil)
  # Then just unquote `context_var` where-ever its used now
end
</code></pre>
<p>That will support both the old implicit style as well as well as allowing someone to not just make it explicit but also name the variable whatever they want.  This is a pattern I use for similar purposes.  <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<p>Can move the options to before the head as well:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defhost [context: ctx], get_move_for_player(player) do
  ...
end
</code></pre>
<p>Whichever you think feels more natural (I’ve seen both forms pretty equally, having it in front means you require the <code>[</code>/<code>]</code> wrapping it though where having it at the end, before the <code>do</code>, means that you don’t).</p>
<p>In addition, both forms let you add more ‘mapping’ variables in the future with trivial ease if you ever need to.  And if you think you don’t want to support the implicit forms (I recommend not to support them personally) then you can use that knowledge to generate more efficient code as well!  <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="113146" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/waspvm-run-webassembly-in-elixir/19129/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-113146" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="113146"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #15"></div>
  </section>
</div>
    <div class="postbit" id="113147" data-post-id="113147">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="OvermindDL1" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/OvermindDL1/120/2677_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  OvermindDL1
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="alexdovzhanyn" data-post="15" data-topic="19129">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/alexdovzhanyn/48/15369_2.png" class="avatar"> alexdovzhanyn:</div>
<blockquote>
<p>because the former has 2 params and the latter has only 1. <a href="https://hexdocs.pm/plug/Plug.Router.html#module-routes" rel="noopener nofollow ugc">Plug does the same thing with their conn variable in the router</a>.</p>
</blockquote>
</aside>
<p>Except you can ‘pop’ the first one if it matches a pattern, like being named <code>ctx</code> or so, that is still awfully implicit though.  ^.^;</p>
<aside class="quote no-group" data-username="alexdovzhanyn" data-post="15" data-topic="19129">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/alexdovzhanyn/48/15369_2.png" class="avatar"> alexdovzhanyn:</div>
<blockquote>
<p>You can! The only thing is that you would need to use the functions defined in the VM itself <a href="https://hexdocs.pm/wasp_vm/WaspVM.html#get_memory/2" rel="noopener nofollow ugc">WaspVM.get_memory/2</a> and <a href="https://hexdocs.pm/wasp_vm/WaspVM.html#update_memory/3" rel="noopener nofollow ugc">WaspVM.update_memory/3</a>, as it takes a reference to the VM directly, and then you can use WaspVM.Memory to interface with the memory. So the above code would be rewritten as</p>
</blockquote>
</aside>
<p>Awesome!!  ^.^</p>
<aside class="quote no-group" data-username="alexdovzhanyn" data-post="15" data-topic="19129">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/alexdovzhanyn/48/15369_2.png" class="avatar"> alexdovzhanyn:</div>
<blockquote>
<p>Yep! you can do this by passing a <code>gas_limit</code> when calling <code>WaspVM.execute</code> :</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">WaspVM.execute(pid, "some_func", [], gas_limit: 100)
</code></pre>
<p>If the gas limit is reached, the program will interrupt and return an error.</p>
</blockquote>
</aside>
<p>Great!  Is there a way to not have it error but instead return a ‘continuation’?  Perhaps something like:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">case WaspVM.execute(pid, "some_func", [], gas_limit: 100) do
  {:ok, return} -&gt; return # this is a returned variable
  {:continuation, cont} -&gt;
    cont.() # Can just call it again to run it with the same options
    # Or perhaps make it take an argument list like `cont.([])` so you can do something like:
    # cont.(gas_limit: 50)
    # To change the certain specific options and pick up where it left off otherwise.
  {:error, reason} -&gt; throw reason # This is a returned hard error
end
</code></pre>
<p>Could just do one-shot continuations is fine, although if possible (maybe via an option if costly, though if memory is a binary it shouldn’t be as it’s copy-on-write, not read) then the continuation could wrap the entire interpreter state so it could be called again multiple times to continue from the save point that the continuation itself wraps (this is a pattern I did in a couple of interpreters I wrote in Elixir).</p>
<p>Also, instead of running the interpreter in another process, have you thought of having a state be passed in/out of everything (like the lua interpreter) so we can just run it in-process (we can always spawn a process if we need), that means it becomes trivial to do things like clone the existing state of the interpreter and all among other capabilities.  <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="113147" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/waspvm-run-webassembly-in-elixir/19129/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-113147" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="113147"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #16"></div>
  </section>
</div>
    <div class="postbit" id="171618" data-post-id="171618">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="marcalchca" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  marcalchca
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hi,</p>
<p>At the Elixir Conf 2019 and in chats I find in 2019 I see a lot about WASM and Elixir/BEAM.<br>
We are now approximately 7 - 9 months after most of the discussions I find. Sure a lot must have happened in between?</p>
<p>How far are we from compiling Elixir to be executed in the browser?<br>
Since I’m taking steps to move to Elixir/Phoenix for PWA-development, the offline development is what I’m missing, so either LiveView can be used with a BEAM running in the browser (?) or we can simply compile Elixir (and LiveView?) to a binary format executed in the browser …</p>
<p>Thanks for helping me have realistic expectations about maturity and the road map …</p>
<p>Best regards<br>
Marc</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="171618" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/waspvm-run-webassembly-in-elixir/19129/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-171618" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="171618"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #17"></div>
  </section>
</div>
    <div class="postbit" id="174146" data-post-id="174146">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="bin" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/bin/120/19117_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  bin
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Awesome</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="174146" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/waspvm-run-webassembly-in-elixir/19129/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-174146" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="174146"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>