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?
<andrewrk> reductum, no. subscribe to this issue to be notified https://github.com/github/linguist/issues/4219
<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> vegcode: std.fmt.bufPrint(buf: []u8, comptime fmt []const u8, args: ...) ![]u8
<hryx> vegecode: There's no holistic documentation of std yet. I'm working on a documentation generator (right now actually) so soon
<hryx> API docs that is, not a tutorial
<vegecode> Thank you.
fiatcurrency has joined #zig
<fiatcurrency> Hi, just got started on the language today, anybody know how to print character as literals rather than their code points?
<vegecode> What does it mean to return a []u8? Is an actual copy of the formatted buffer returned in addition to the buffer that is a parameter?
<hryx> vegecode: Nope, a []u8 is a slice, which is only a pointer plus length information
<hryx> so it's not an entire copy of the underlying array, just a reference
<hryx> actually wait, let me make sure I understand something real quick...
<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]
sjums has joined #zig
<sjums> Is this expected when building release-fast? https://hurtig.ninja/0e893457/image-png
<j`ey> you mean non-deterministic behaviour?
<j`ey> and I guess the answer is obviously "no" :P
<sjums> same input with same code returning different results :P
<sjums> It's a cool feature and all, but I'm unsure what to use it for ._.
<sjums> The correct result, according to Advent of Code, is 5000
sjums has quit [Ping timeout: 256 seconds]
wootehfoot has joined #zig
porky11 has joined #zig
Hejsil has joined #zig
sjums has joined #zig
sjums has quit [Client Quit]
sjums has joined #zig
Hejsil has quit [Ping timeout: 256 seconds]
DutchGh0st has joined #zig
<DutchGh0st> is there a std function that converts []u8's to an integer type?
<DutchGh0st> allright cool!
<DutchGh0st> Guess its time for Advent of Code in Zig
sjums has quit [Ping timeout: 246 seconds]
DutchGh0st has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
Hejsil has joined #zig
DutchGh0st has joined #zig
<DutchGh0st> with a HashMap,
<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> what day are you sjums ?
<sjums> 2.1 done
<sjums> Up to*
<DutchGh0st> part1
<sjums> Wait, does part one entirely run at compile time?
<j`ey> yep
<DutchGh0st> it does !
<DutchGh0st> you could do all puzzles at compiletime I guess
<DutchGh0st> however, its a bad idea
<DutchGh0st> you have to use constant array's, and figuring out what the length of the array should be, and...yeah
<DutchGh0st> plus comptime might need much ram, so only do it for little puzzles like day1 part1
<DutchGh0st> I like comptime :D
<sjums> Need to read a little more about that. And about @embedFile
<DutchGh0st> j`ey: , are you in the Rust mibbit chat knows as j_ey ?
<sjums> I wrote way too much code reading in the input file! :p
<DutchGh0st> *known
<DutchGh0st> heh
<j`ey> DutchGh0st: yep
<DutchGh0st> embed file does it at compiletime
<DutchGh0st> ohh hey! Dodo here!
<j`ey> DutchGh0st: I know :)
SimonNa has quit [Remote host closed the connection]
so has quit [Ping timeout: 246 seconds]
so has joined #zig
<DutchGh0st> huh
<DutchGh0st> how do I return a `?!u32` ?
<hryx> actually DutchGh0st I ran into that recently too. I'd love to know
<DutchGh0st> andrewrk: ?
sjums has quit [Ping timeout: 250 seconds]
DutchGh0st has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
DutchGh0st has joined #zig
return0e has quit [Read error: Connection reset by peer]
return0e_ has joined #zig
<andrewrk> DutchGh0st, guide the compiler with an implicit cast
<DutchGh0st> an implicit cast?
<DutchGh0st> but I cant write ' fn foo() ?!i32`
<DutchGh0st> it complains about the ?Ii32
<DutchGh0st> error: invalid token: '!'
<andrewrk> oh I see your question now. you can't infer the error set if the return type is not an error union
<DutchGh0st> yeahh
<DutchGh0st> and what if you want to Maybe return an error?
<andrewrk> this uncovered a compiler bug. it generates invalid llvm
<DutchGh0st> hehe
<DutchGh0st> but good!
<j`ey> andrewrk also someone got weird behaviour this morning
<j`ey> 12:35:53 < sjums> Is this expected when building release-fast? https://hurtig.ninja/0e893457/image-png
<DutchGh0st> I wonder how the error unions work btw, do you create a new union of all possible errors at compiletime?
<andrewrk> j`ey, it's not enough to see that output, I would have to see the source
<andrewrk> debug builds cannot catch all undefined behavior
oats has left #zig ["WeeChat 2.3"]
DutchGh0st has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
DutchGh0st has joined #zig
<DutchGh0st> I wish fancy Iterator chaining was part of stdlib!
DutchGh0st has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
DutchGh0st has joined #zig
wink_ has joined #zig
DutchGh0st has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
DutchGh0st has joined #zig
sjums has joined #zig
sjums has quit [Client Quit]
sjums has joined #zig
<wink_> The following test fails with "lld: error: undefined symbol: __fixdfti"
<wink_> test "i65" { var oneF64 = f64(1); assert(1 == @floatToInt(i65, oneF64)); }
<wink_> But is OK casting to a i64:
<wink_> test "i64" { var oneF64 = f64(1.0); assert(1 == @floatToInt(i64, oneF64)); }
<j`ey> also 1 and 1.0?
<andrewrk> wink_, solution is to port __fixdfti from llvm's compiler_rt project into zig's std/special/compiler_rt/*
<wink_> k, I'll look into doing that, txs
DutchGh0st has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
DutchGh0st has joined #zig
<DutchGh0st> mh, I wonder
<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]
Zaab1t has quit [Quit: bye bye friends]
DutchGh0st has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
v1zix has joined #zig
edr has quit [Ping timeout: 244 seconds]
edr has joined #zig
<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?
<andrewrk> ;)
<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 :-/