3 ms·
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'
by ww520 1y 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?
- AndyKelley 1y agoYes, that is precisely what "non-generic" means.
- ww520 1y agoThat's excellent! Thanks for the changes.
- norman784 1y agoI recommend watch this video https://youtu.be/x3hOiOcbgeA https://youtu.be/x3hOiOcbgeA
- ww520 1y agoNice 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.