Download Game! Currently 60 players and visitors. Last logged in:SuzukiShutatMahjongFloppy

Blitzer's Blog >> 72037

Back to blogs index
Posted: 05 Sep 2026 10:46 [ permalink ]
Drafting the text:
"Allowing a dynamic regex/wildcard pattern at runtime instead of compile-time
syntax (like sync int var;) is a much smarter approach. It keeps the AST
compiler lean and shifts the configuration entirely into the LPC domain.
Because our VM is built on Node.js, we can achieve this transparently using
JavaScript's native Proxy object. The Proxy can wrap the target object and
silently intercept every property assignment (set operation).
Here is the exact architectural blueprint to achieve this:
1. The mesh_sync_object EFUN
When mesh_sync_object(this_object(), "game_scores", "^score_.*") is invoked,
the EFUN does three things:
Registers the Topic: It binds the object's __filename to the "game_scores"
topic in a global registry.
Compiles the Regex: It converts the "^score_.*" string into a native RegExp.
Injects the Proxy: It wraps the object's underlying context in a Proxy.
2. The Transparent Mutation Interceptor
Whenever the LPC code does score_blue = 5;, the AST generates _this.score_blue
= 5;. The proxy intercepts this automatically:

/ Inside efuns.d/10_mesh.js
mesh_sync_object: (ob, topic, pattern) => {
    const regex = new RegExp(pattern);

    // Wrap the original object to trap mutations
    const proxiedOb = new Proxy(ob, {
        set(target, prop, value) {
            // Perform the actual assignment
            const success = Reflect.set(target, prop, value);

            // If it matches the wildcard, push to the mesh outbox
            if (success && regex.test(prop)) {
                rt.__OUTBOX.push({
                    topic: topic,
                    source: target.__filename,
                    property: prop,
                    value: value,
                    timestamp: Date.now()
                });
            }
            return success;
        }
    });

    // Replace the reference in the master object pool
    rt.master_objects[ob.__filename] = proxiedOb;
    return 1;
}