Hacker News new | ask | show | jobs
by ww520 352 days ago
One issue I have with the old reader/writer pattern is that it is not easy to store them in a struct. Reader and writer are passed into a function as 'anytype' which implements any of the read() or write() functions. Often time in a struct's init() function, I want to take in a reader/writer and store it for later use. It's close to impossible since I don't know what type of the field of the struct to store them.

Does the new change make it easier to store reader/writer in a struct?

2 comments

I recommend watch this video https://youtu.be/x3hOiOcbgeA
Nice video. I especially like the new 'labeled switch' feature providing a freeform control flow, and the watch/incremental compile feature. I used to use Rust's watchexec to do zig build on changes; now the watch feature is built natively in zig. The IO based async/await stuff seems to be the right direction; it's following the familiar Allocator pattern. The integrated fuzz testing into the compiler tool chain is fantastic; I can write much less unit tests now.

Zig.day looks like a wonderful way to do laid back hackathons. Looking forward to one coming up.

Yes, that is precisely what "non-generic" means.
That's excellent! Thanks for the changes.