Get the latest tech news

Zig's (.{}){} Syntax


A look at some unfriendly Zig syntax

This is a combination of three separate language features: generics, anonymous struct literals and default field values. Thinking of Node(i32) as a type can take a bit of getting used to, but once you accept that it's no different than any other struct, the 2nd initialization hopefully makes sense. I've written more about generics before and, in the next post, we'll talk about a new Zig feature, declaration literals, which improve the readability of this type of code.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of zig

zig

Photo of syntax

syntax

Related news:

News photo

Mergiraf: a syntax-aware merge driver for Git

News photo

Adding syntax to the CPython interpreter

News photo

Zdotenv – Dotenv Loader for Zig