Axiom · dark
Modules and Self Type
Axiom uses compile-time Self-bound interfaces instead of runtime-vtable-first OOP.
The same application code can target Linux, Windows, INVARIANT OS, or bare metal while calls still resolve statically.
A file-system interface
Self-bound interfaceAxiom
1file_system(Self):2 read(Self self, text path) -> result<bytes, io_error>3 write(Self self, text path, view<const u8> data) -> result<void, io_error>4END file_system1
Self stands for the concrete implementation type.
2
Required operation.
3
Another required operation.
4
No hidden vtable is implied.
A Linux implementation
Concrete implementationAxiom
1linux_fs:2 read(linux_fs self, text path) -> result<bytes, io_error>:3 RETURN linux_os.read_file(path)45 write(linux_fs self, text path, view<const u8> data) -> result<void, io_error>:6 RETURN linux_os.write_file(path, data)7END linux_fs1
Concrete type.
2
Signature satisfies the interface.
3
The OS module performs syscall/ABI-specific work.
5
Same idea for writes.
Generic application code
No runtime polymorphismAxiom
1-- FS enable if file_system(FS)2load_config(FS fs, text path) -> result<config, app_error>:3 const bytes raw = fs.read(path)?4 RETURN config.parse(raw)1
The generic parameter must satisfy the Self interface.
2
The function does not care which OS implementation it receives.
3
Static dispatch resolves during semantic linking.
4
The remaining code is ordinary application logic.