Get the latest tech news

In Zig, what's a writer?


Karl Seguin's Blog - A mix of coding and creative writing

Even though our write function returns an explicit error, that type information is lost when we convert our DummyWriterAny to a AnyWriter. I say "usually", because there's no guarantee; it relies on all of us agreeing that a variable named writer of type anytype only ever uses methods available to a GenericWriter. If I understand correctly, the motivation for this design, was reducing code bloat while providing a mechanism to preserve typed errors.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of writer

writer

Photo of zig

zig

Related news:

News photo

Zig: What to Expect from Release Month

News photo

Zig's comptime is bonkers good

News photo

I wrote a Game Boy Advance game in Zig