+</span></span></code></pre></div><p>There is only ever one <em>instance</em> of a module in a program, so these are <em>effectively</em> global variables. Writing these as <em>struct fields</em> rather than literally as global <code>var</code>s means that <strong><em>Mach moduloe’s global state fields are globally addressible</em></strong> (its possible to walk <em>all modules used in the program</em>, then walk over <em>all their state fields</em>, inspecting their data types, and reading/writing their values at runtime - which is super useful for debug tooling and more!)</p><h2 id=modules-can-have-_systems_>Modules can have <em>systems</em></h2><p>Similar to how we declared <code>pub const mach_module = .foo_name;</code>, a module can declare that it has <em>systems</em> with specific names:</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-zig data-lang=zig><span style=display:flex><span><span style=color:#66d9ef>pub</span> <span style=color:#66d9ef>const</span> mach_systems <span style=color:#f92672>=</span> .{ .main, .init, .tick, .deinit };
0 commit comments