Dynamic Static Dispatch for Zig
Find a file
LordMZTE fe27cf710f
All checks were successful
/ test (push) Successful in 58s
ci: use Zig 0.13.0
2024-06-26 11:28:14 +02:00
.forgejo/workflows ci: use Zig 0.13.0 2024-06-26 11:28:14 +02:00
src chore: port to latest Zig 2024-03-18 18:52:16 +01:00
.gitignore chore: update .gitignore for zig 0.13 2024-06-26 11:24:57 +02:00
build.zig build: using b.path 2024-06-22 21:41:07 +01:00
LICENSE init 2023-04-29 14:04:23 +02:00
README.md init 2023-04-29 14:04:23 +02:00

Statspatch — dynamic static dispatch for Zig

Statspatch is a library that can build a union(enum) dynamically to replace dynamically dispatched types.

Why?

This library makes for an alternative for VTable types (like std.mem.Allocator). This allows for extensibility without the performance drawbacks that come with VTables (no pointer indirections).

Statspatch does this by creating a type dynamically given a prototype that defines the API and a list of all implementors.

This might seem non-extensible at first. For example, if I'm writing a GUI library using Statspatch for Widgets, how would you add your own widgets? Simple! My library can @import("root") to get your root module, and then you declare a list of your own widget types. When my library constructs its widget type using Statspatch, your widgets will also be added.

Usage

  1. Add statspatch to your build.zig.zon
  2. Refer to the tests and documentation in main.zig