pub fn dumpToFile(self : *Self, file : std.fs.File) !void {
var b : [16384] u8 = undefined;
var w = file.writer(&b).interface;
try w.print("Start Pattern: 0x{x:0>2}\n", .{self._startPattern});
...
try w.flush();
Previously
pub fn dumpToFile(self : *Self, file : std.fs.File) !void {
var w = file.writer();
try w.print("Start Pattern: 0x{x:0>2}\n", .{self._startPattern});
Correct? Problem is getting a
/opt/zig/zig-x86_64-linux-0.15.1/lib/std/posix.zig:1376:22: 0x115d381 in writev (std.zig)
.BADF => return error.NotOpenForWriting, // Can be a race condition.
^
/opt/zig/zig-x86_64-linux-0.15.1/lib/std/fs/File.zig:1770:21: 0x115ad83 in drain (std.zig)
return error.WriteFailed;
I run this code on the std.fs.File.stdout()⌠and there is no race condition as it is a single threaded app (and obviously it is open)
Used to work out of the box⌠failing on printing the slice now.
Guys, I am an average Joe (on the best of days) - but it feels like there is an overcomplication in elementary things making the simplest, fundamental things tough with fiery hoops and landmines to boot.
I am at a point where I am considering sticking to the os/posix classes and skipping many reference library items entirely.
If your code still contains this line, then it canât work:
you are copying the Io.Writer out of the temporary File.Writer,
destroying the interfaces implementation, you canât copy .interface as a separate value.
Agreed, and good code. I do it merely to let the powers know, that the simplest of things are breaking, and things that were obvious, are not obvious anymore, without reasonable documentation or example. I understand it is free, I understand it is bleeding edge, I see Zig filling a void in a time where there are millions of languages to choose from and it is still special, I understand all of the above, but after investing much time in it, these issues are worrying me; as the most basic of things cannot recompile after update (and I keep my code simple), some of which donât give compile errors and you only see at runtime, meaning you would have to create unit tests for everything (time which a 2 man company simply does not have).
Bottom line, worried about the things that I am not aware of yet that has changed/broken, tired of long hours as we all are and disappointed that I have to backtrack profusely and worried about what this holds for the future.
Thanks @Sze solution has better longevity imho. But thanks for your suggestion⌠the issue is not the inability to print as hex, but that fact that something seemingly obvious and simple that worked does not anymore. (and like script, it fails only when you run it⌠which kind of defeats some of the purposeâŚ)
The thread is in the vicinity, but really not that obvious to impact something that did not have a format in the first place.
Again, this is not a complaint, it is just a reminder to myself that there is much more work and rework to follow - and to take a weekend and make sure what pain I want to endure.
Thanks @squeek502 - yes I am aware of that method.
There however is a big convenience both in code and conceptualizing the output in working with format strings⌠I guess @Sze 's reference to implementing the format interface is the long term way to go; more often than not.
Thanks for your assistance. I have now converted my readers/writers and formatters (quite a few places). I really was not looking forward to it (as I guess was obvious), but all is well again. I am not fully with the benefits of the new patterns yet, but I am hopeful that we will get good yardage from it.
Thanks again to all.
Off topic, was sitting with a C and C++ problem today⌠and in an off few minutes I went to look at one of the main Zig âcompetitorsâ. The C/C++ problem was livable yet unnecessary⌠the other language, I was just again perplexed at the amount of red tape involved and the patterns it impose.
Neither the language nor the standard library is stable. More breaking changes are coming. I donât mind breakages, especially if that means a better 1.0. The thing is, we donât yet know if 1.0 would be better because we havenât crossed that bridge yet; we have to trust the maintainersâ conviction that it will.
Imagine if pre-1.0 Zig had a policy where each breaking change had a backward compatible counterpart. That would put so much extra burden on an already-small team. I, for one, would much rather see their time spent on more important things, such as improving incremental compilation, expanding self-hosted back-end support, improving runtime safety, etc.
There were some changes in 0.14 I didnât like, but after some time I either came around or just got used to it. I think this will be true for 0.15, too.
I totally understand. If there were unlimited budgets and unlimited hands it would have been cooked already. The communication/documentation is lacking for people that have âday jobsâ on 1000 other things. I picked a very stressful time to upgrade as well, donât know what I was thinking. It fortunately isnât core stuff -just things to get me going into learning Zig (so I spend much less time at it than I want/need to).
That said, if it wasnât for the forum I would have given up long ago, as I simply donât have the time to etc etc. The tooling however is still a major concern⌠The cross compiling and âembedded clibâ is gold.