You hit the nail on the head!
The JIT compiler is lazy by design. If you look at `core/runtime.js`, the
`load_object` function first checks if a blueprint for the object already
exists in memory. Because you ran `make web` *before* adding the `seed()`
function, the old version of `genesis_grid.c` was hard-baked into the
`index.html` payload.
When you reloaded the browser, the DMZ *did* sync the new text file to the
VFS, but the VM completely ignored it because it already had the old blueprint
cached in RAM! When you tried to call `seed()`, the LPC `call_other` safely
swallowed the error and returned `0` because the function didn't exist on the
cached object.
### The Immediate Fix
For right now, just run `make web` (or `node build_web.js`) one more time to
bake the newly updated `genesis_grid.c` into the baseline payload. Refresh the
browser, run the seed command, and you will see the simulation shatter the
empty space!
### The Hot-Reload Upgrade
To stop you from having to run `make web` every time you tweak the physics
engine, we can easily add a "Hot Reload" interceptor directly to your DOM
REPL. We just need to manually delete the cached blueprint and destruct the
old object from memory; the next time you call `load_object`, the VM will be
forced to dynamically re-compile the freshest code from the VFS!
In your `template.html`, find the **DOM REPL LOGIC (Section 5)** and add this
`/update` command right below the `clear` command interceptor:
```javascript
// UX INTERCEPT: Handle "clear" directly in the DOM
if (val.trim() === "clear") {
document.getElementById('output').textContent = "";
return;
}
// NEW: Hot-Reload interceptor!
if (val.trim().startsWith("/update ")) {
let target = val.trim().substring(8).replace(/\.c$/, '');
// Strip .c if provided
// 1. Destruct the active master object if it exists
if (window.__rt.master_objects[target]) {
window.__rt.destruct(window.__rt.master_objects[target]
);
delete window.__rt.master_objects[target];
}
// 2. Wipe the compiled blueprint from RAM
delete window.__rt.blueprints[target];
sys.stdout.write(`
[VM] Cache cleared for ${target}. Next load_object() will JIT compile from
VFS.
`);
return; // Bypass sending to LPC
}
```
Once you patch this in, your development loop becomes blisteringly fast:
1. Edit `genesis_grid.c` in your Linux terminal.
2. The Host Agent automatically pushes the file to the browser.
3. Type `/update gamelib/mesh/genesis_grid` in your Web REPL.
4. Type `eval load_object("gamelib/mesh/genesis_grid")` to instantly compile
and run the new code!
Run the `make web` rebuild so we can see the glider and gravity blocks in
action! What does the display output look like?