Tech article

We have traits at home

Hacker News | Oct 22, 2026 | Ygg2

Automated excerpt

I would propose a new convention for defining compile-time type contracts as Traits in Zig. We would probably end up fn add(lhs: Rational, rhs: Rational) Rational {... } fn sub(lhs: Rational, rhs: Rational) Rational {... } fn mul(lhs: Rational, rhs: Rational) Rational {... } fn div(lhs: Rational, rhs: Rational) Rational {... } fn add(lhs: Complex, rhs: Complex) Complex {... } fn sub(lhs: Complex, rhs: Complex) Complex {... } fn mul(lhs: Complex, rhs: Complex) Complex {... } fn div(lhs: Complex, rhs: Complex) Complex {... } rationals.

Selected automatically from source text; not independently written or fact-checked. Read the original for full context.

Read the original article

Read next

AI briefing: recent picks

More stories to explore