đź“ťZig functions are colorless

tags

Zig Function color

Zig infers whether a function is async, and allows async/await on non-async functions, which means that Zig libraries are agnostic of blocking vs async I/O. Zig avoids function colors.

The Zig Standard Library implements an event loop that multiplexes async functions onto a thread pool for M:N concurrency. Multithreading safety and race detection are areas of active research.

—In-depth Overview ⚡ Zig Programming Language

  • async/await keywords are still there

  • functions are still divided between async and normal, though compiler does this automatically and does not require/allow annotations

  • calling an async function without async implicitly inserts await async, so that

    _ = try socket.write("Hello, world!\n");
    // becomes
    _ = try await async socket.write("Hello, world!\n");
    
  • async/await become no-op in the blocking io_mode.

Resources

Backlinks