ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
Hejsil has quit [Quit: Page closed]
<reductum>
andrewrk: Did GH give an estimate of when the syntax highlighting would be rolled out?
<seedofonan>
I can't google up an example of a freestanding target like arm7em (except on github gulitsky/zig-arm-cortex-m-semihosted-hello-world, which doesn't help at all). I can get an .elf output, but there's only debug sections in it. Does anyone have a link to an embedded example?
seedofonan has quit [Ping timeout: 256 seconds]
emekoi has quit [Ping timeout: 256 seconds]
porky11 has quit [Quit: Leaving]
vegecode has joined #zig
walac has quit [Ping timeout: 252 seconds]
vegecode has left #zig [#zig]
walac has joined #zig
vegecode has joined #zig
<vegecode>
Can someone tell me which file in the standard library contains a function that will do the equivalent of sprintf? I have an integer and I want to convert it to text in a buffer. I see how to do it when sending to stdout, but not just to a buffer.
reductum has quit [Ping timeout: 246 seconds]
<vegecode>
Is there any kind of general overview of the standard library anywhere? The documentation of the language is pretty good, but I haven't found anything about the standard library, besides of course just looking in the standard library itself.
<MajorLag>
fiatcurrency, `"{}", someu8` would print the u8 as a number, `"{c}", someu8` treats the u8 as a character.
<hryx>
bufPrintIntToSlice is returning a "window" of `buf` which was passed as a parameter, and therefore alread allocated by the caller
<fiatcurrency>
Thank you, MajorLag
<vegecode>
Thanks hryx, that makes sense. Instead of returning the number of characters printed like sprintf, it returns a slice, which not only has the length parameter encoded in it if that is what the caller wants, but it can then be used in further function calls more easily. That's nice.
<vegecode>
Is there syntax to dereference a struct pointer and access a field at the same time like mystruct->somefield in c?
<MajorLag>
mystruct.field
<MajorLag>
the dereference is implicit
<vegecode>
Thanks, I thought I tried that and it didn't work, but now it is working so I must have been confused.
emekoi has joined #zig
vegecode has quit [Quit: WeeChat 2.2]
reductum has joined #zig
suirad has quit [Ping timeout: 256 seconds]
_whitelogger has joined #zig
emekoi has quit [Quit: Page closed]
fiatcurrency has quit [Ping timeout: 256 seconds]
benjikun has quit [Ping timeout: 246 seconds]
benjikun has joined #zig
suirad has joined #zig
reductum has quit [Quit: WeeChat 2.3]
basro has quit [Disconnected by services]
basro_ has joined #zig
basro_ is now known as basro
Zaab1t has joined #zig
forgot-password has joined #zig
forgot-password has quit [Ping timeout: 268 seconds]
<DutchGh0st>
if you Iterate over it, you get ?*KV 's
<DutchGh0st>
so you do like ` while(iter.next()) |entry| {}`
<DutchGh0st>
but if I then write `if (entry.*.value == 2) {//...}` , and it complains that an integer value 2 van not be implicitly casted to type *u32
<DutchGh0st>
but didn't I just dereference the entry?
<DutchGh0st>
OH
<DutchGh0st>
I also wrote ' && ' in the if's condition
<DutchGh0st>
gotta use ` and` :P
_whitelogger has joined #zig
sjums has joined #zig
<sjums>
DutchGh0st: I believe it's entry.?.value
<sjums>
Instead of entry.*.value
<DutchGh0st>
no the while look does that already
<DutchGh0st>
loop*
<DutchGh0st>
thats the |entry| part
<sjums>
I'm 95% sure...
<sjums>
That I'm wrong!
<DutchGh0st>
:D
<DutchGh0st>
Doint some advent of code finally in Zig
<DutchGh0st>
*doing
<sjums>
Currently learning zig. By doing AoC
<sjums>
Coming from C# the learning curve is easily described as steep!
<DutchGh0st>
yeahh
<DutchGh0st>
comming from Rust, so its...fine, sometimes
<DutchGh0st>
its just that I have to lookup the types each time xD
<DutchGh0st>
calling ` /usr/bin/time -f "mem=%M RSS=%M elapsed=%E cpu.sys=%S .user=%U" ` on a release-build in Rust gives: real 0m0,049s
<DutchGh0st>
the Zig version: real 0m2,255s
<DutchGh0st>
where I use -Drelease-fast=true
reductum has joined #zig
<DutchGh0st>
huh
<DutchGh0st>
I just wrote ` noreturn` inside a hashmap's value type
<DutchGh0st>
and my computer frooze
Hejsil has quit [Quit: Page closed]
vegecode has joined #zig
<vegecode>
Could someone point me to an example of a main function that return a u8, but also uses functions inside of it that can return errors? I'm getting an error in bootstrap.zig.
<andrewrk>
vegecode, you'll need to use `if` or `catch` to deal with errors
wootehfoot has quit [Read error: Connection reset by peer]
<v1zix>
I think I might be missing something obvious, but how does one append a string read from a file to an ArrayList of strings? I saw what looks like an example in std.debug with readStringRaw but I'm still missing something
<andrewrk>
what type is your string read from a file?
<v1zix>
Yep haha, one other question how does the list in that function get cleaned up without calling list.deinit()? Does that happen when the allocator is cleaned up?
<reductum>
vegecode: Still getting familiar with Zig's standard lib, but another way is to just read the whole file into an allocated array:
<andrewrk>
v1zix, it doesn't get cleaned up in the code I linked. I didn't bother cleaning up memory because the program is designed to run once and then exit, so there's no point of dealing with memory cleanup
<reductum>
Ah. Meant to tag v1zix up there, not vegecode.
<v1zix>
Cool, thanks for the help
reductum has quit [Quit: WeeChat 2.3]
<andrewrk>
I'm running into the painful combination of error sets + interfaces right now :-/