ChanServ changed the topic of #zig to: zig programming language | https://ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
craigo has quit [Ping timeout: 260 seconds]
<marijnfs> true the loop over fields is comptime i guess. I mean the infinite loop is then at runtime.
<marijnfs> msg is a c-type, but could be removed for the example
ur5us_ has quit [Ping timeout: 264 seconds]
<marijnfs> this comptime loop was needed to find the right union, not sure if there is a better way to do it now?
arielp has joined #zig
zags has quit [Ping timeout: 256 seconds]
notzmv has joined #zig
v0idify has quit [Remote host closed the connection]
v0idify has joined #zig
ur5us_ has joined #zig
arielp has left #zig ["WeeChat 3.0.1"]
leon-p has quit [Quit: leaving]
notzmv has quit [Ping timeout: 256 seconds]
marijnfs has quit [Quit: WeeChat 2.8]
dfacto has joined #zig
gazler_ has joined #zig
gazler has quit [Ping timeout: 276 seconds]
earnestly has quit [Ping timeout: 245 seconds]
brzg has joined #zig
craigo has joined #zig
powerofzero has quit [Ping timeout: 264 seconds]
powerofzero has joined #zig
Techcable has quit [Quit: Techcable - The Lounge]
arwn has joined #zig
Techcable has joined #zig
<arwn> Hey I want to sort an array of `card = struct{rank:i32, suit:i32}`'s how do i create a custom compare function so i can pass it to std.sort.sort()?
<g-w1> you mean lessThan?
<brzg> just make an `fn cardLt(ctx: void, a: card, b: card) bool`, which returns true if card a should be considered less than card b
<brzg> then pass .{} for context and cardLt for lessThan when calling sort
<g-w1> dont pass .{} just pass {}
<g-w1> {} is a value of type void
eax has joined #zig
<arwn> alright i'll try that, thanks.
texno has quit [Ping timeout: 260 seconds]
hspak has quit [Quit: bye]
powerofzero has quit [Remote host closed the connection]
powerofzero has joined #zig
hspak has joined #zig
texno has joined #zig
earnestly has joined #zig
<arwn> very cool, it works. if I wanted to figure out what `context` was for where would I go? the ziglang docs don't seem to explain it.
Techcable has quit [Quit: ZNC - https://znc.in]
<g-w1> context is probably what you pass to the compare function
<brzg> it's in case you'd need data to handle the comparison beyond just the two items to compare
eax has quit [Remote host closed the connection]
notzmv has joined #zig
notzmv has quit [Ping timeout: 260 seconds]
brzg has quit [Quit: leaving]
<arwn> Is there a way to loop over an enum other than converting the last element to an int?
<g-w1> loop over in what way?
<arwn> I want to generate a deck of cards. i have two enums representing suit and rank. I want to have two nested for loops that generate every card. like `for (suit in suit) { for rank in rank } append(cards, Card{suit, rank})}} or something.`
<arwn> my curly braces are wrong but hopefully you get the idea.
powerofzero has quit [Ping timeout: 245 seconds]
<g-w1> hmm, you can try to use std.meta.fields and iterate through them
xackus_ has joined #zig
xackus has quit [Ping timeout: 256 seconds]
powerofzero has joined #zig
_whitelogger has joined #zig
<arwn> am i stupid? is there not a better way to write the makeDeck function?https://pastebin.com/raw/L3dHk8kQ
timmydo has joined #zig
<timmydo> has anyone tried packaging zig on guix before? I tried but got an error: http://paste.debian.net/plain/1188367
gpanders has quit [Remote host closed the connection]
gpanders has joined #zig
Techcable_ has joined #zig
powerofzero has quit [Ping timeout: 264 seconds]
ur5us_ has quit [Ping timeout: 264 seconds]
a_chou has joined #zig
a_chou has quit [Remote host closed the connection]
a_chou has joined #zig
<arwn> aha the std.meta.fields function almost does what I want and that's goon enough for now.
<arwn> thanks for the suggestion.
arwn has quit [Remote host closed the connection]
sord937 has joined #zig
ur5us_ has joined #zig
eax has joined #zig
a_chou has quit [Quit: a_chou]
ur5us_ has quit [Ping timeout: 264 seconds]
decentpenguin has quit [Quit: ZNC crashed or something]
decentpenguin has joined #zig
eax has quit [Quit: eax]
waleee-cl has quit [Quit: Connection closed for inactivity]
bitmapper has quit [Quit: Connection closed for inactivity]
hidayat has joined #zig
cole-h has quit [Ping timeout: 260 seconds]
tnorth_ has joined #zig
powerofzero has joined #zig
tane has joined #zig
<tane> howdy
jokoon has joined #zig
<ikskuh> heya
<tane> ikskuh, do you have holidays too? :)
<ikskuh> nope, just usual morning routine (and hanging out here)
squeek502 has joined #zig
hidayat has quit [Quit: Connection closed]
ur5us_ has joined #zig
ur5us_ has quit [Ping timeout: 264 seconds]
ur5us_ has joined #zig
ur5us_ has quit [Ping timeout: 264 seconds]
ur5us_ has joined #zig
zags has joined #zig
ur5us_ has quit [Ping timeout: 264 seconds]
notzmv has joined #zig
tnorth_ is now known as tnorth
tane has quit [Quit: Leaving]
notzmv has quit [Ping timeout: 264 seconds]
craigo has quit [Ping timeout: 245 seconds]
craigo has joined #zig
<ikskuh> i found a critical bug in "zig fmt"
<ikskuh> somehow some emoji force zig fmt to take up *all* ram
<ikskuh> cannot reproduce it though
dyeplexer has joined #zig
leon-p has joined #zig
powerofzero has quit [Read error: Connection reset by peer]
powerofzero has joined #zig
notzmv has joined #zig
tane has joined #zig
notzmv has quit [Ping timeout: 260 seconds]
sord937 has quit [Remote host closed the connection]
sord937 has joined #zig
notzmv has joined #zig
SebastianM has joined #zig
<dutchie> is there a way to set std.log's log_level at runtime without writing a custom log function?
SebastianM has quit [Quit: -a- Bye Bye]
<dutchie> somewhat related nit: std.debug.getStderrMutex but std.io.getStdErr
<ikskuh> dutchie: no, afaik not
vent has joined #zig
<tane> dutchie, good point, there's a lot of inconsistencies in the stdlib as of now
<ikskuh> tane: that might be because a lot of people contribute and change stuff
<tane> I guess there's a zig-parser in zig by now
<tane> yes
<tane> what I wanted to do last year was to export all symbols and look for inconsistencies automatically
<tane> but back then the only parser was in C-like C++
<tane> maybe it's a better time now
<ikskuh> zig std has a zig parser for at least a year
<ikskuh> zig fmt is based on it already for a long time
<tane> ok nice, I guess it was around 0.5.0 that I tried this
<ifreund> std.zig predates 0.5.0
<tane> ok, whatever - maybe I didn't see it then
<ifreund> that's also very possible, the std documenation is not exactly a priority
<tane> I guess I just looked at the compiler and how it parsed its stuff then went with it
bitmapper has joined #zig
nickster has left #zig ["The Lounge - https://thelounge.chat"]
nickster has joined #zig
<tnorth> Hey there. I'm trying to debug a Zig program with GDB. I have a struct (foo) with a member bar = ?[]@This(). When breaking in GDB after intialization (bar is allocated with a c_allocator) and printing foo, I get: $1 = {bar = <error reading variable>}. Printing foo.bar says: "That operation is not available on integers of more than 8 bytes". Moreover, I can't index it (print foo.bar[0] for instance). Is that normal? Is
<tnorth> there a workaround?
<ikskuh> what about foo.bar.ptr ?
<tnorth> ikskuh: "There is no member named ptr"
<tnorth> I expected GDB to find the address to the beginning of bar
<Raito_Bezarius> has getEnvPosix disappeared in the std.os namespace?
<Raito_Bezarius> If so, is the canonical way to read from env vars to allocate something?
<ifreund> Raito_Bezarius: std.os.getenv()?
<Raito_Bezarius> I was mislead by https://github.com/ziglang/zig/issues/841 :>
<Raito_Bezarius> Thanks ifreund !
<Raito_Bezarius> Is it possible to look at a env var at compile-time?
<Raito_Bezarius> comptime const someFlag = std.os.getenv("xxx") orelse false;
<Raito_Bezarius> something like this
<ifreund> no
<g-w1> that would be unreproducable builds
<g-w1> use the -Dpattern in the build.zig
<ifreund> you can look at environment variables in your build.zig and pass the to your program as build_options if you really want
<Raito_Bezarius> I'm already in the build.zig file in fact
<Raito_Bezarius> I know this env var will always be some reproducible path
<Raito_Bezarius> (it comes from the nix store)
<ifreund> that sounds like it is a build time configuration option
<Raito_Bezarius> Hm, it has no relation with the code
<ifreund> what if I want to build your program on my (non-nix) system?
<Raito_Bezarius> To be precise, this is part of a run command of QEMU with OVMF firmware
<Raito_Bezarius> the OVMF firmware path is passed as an env var
<Raito_Bezarius> Because there is no standard way to discover where the firmware is
TheLemonMan has joined #zig
<Raito_Bezarius> Nix is a requirement of the project, but there are escape hatches, indeed
<ifreund> andrewrk: could use your input on which path to take here when have a minute: https://github.com/ziglang/zig/issues/8161
<qbit> ++ for not having a hard req on nix :P (there is little to no support in nix for *BSD .. so making your application work there is pain)
notzmv has quit [Ping timeout: 246 seconds]
grive has joined #zig
notzmv has joined #zig
<TheLemonMan> the m68k backend for LLVM is ready to land, noice
<ikskuh> whooot?
<ikskuh> seriously?!
<ikskuh> :O
<ikskuh> may i scream in excitement?
<TheLemonMan> time to dust off the Amiga ?
<ikskuh> it's ready to use already *grin*
nvmd has joined #zig
haliucinas has quit [Read error: Connection reset by peer]
haliucinas has joined #zig
clee has joined #zig
<clee> having trouble figuring out how to do something pretty basic; using zig 0.6.0, how do I open an absolute path as a directory and walk all of its subpaths?
jokoon has quit [Quit: Leaving]
<ikskuh> clee: are you a fresh zig user?
<tane> clee, try std.fs.walkPath
<clee> ikskuh: yup
<ikskuh> i heavily recommend using 0.7.1
<clee> tane: I don't see that std.fs.walkPath on https://ziglang.org/documentation/0.6.0/std/#std;fs
<clee> ikskuh: it doesn't appear to be packaged for Debian bullseye yet
zags has quit [Ping timeout: 245 seconds]
<ifreund> you can get static tarballs from ziglang.org
<g-w1> dont use those docs, they are very bad
<clee> hahahaha
<tane> clee, yeah.. "grep" through the source of stdlib to get ground truth :)
<clee> okay so what docs should I use to learn the stdlib?
<tane> the source
<ifreund> yeah the autogenerated std docs are much worse than reading the source code
<g-w1> the source code
<oats> the stdlib code is pretty great, very clean and understandable
nvmd has quit [Quit: Later nerds.]
Akuli has joined #zig
sord937 has quit [Remote host closed the connection]
sord937 has joined #zig
zags has joined #zig
v0idify has left #zig ["Leaving"]
zags_ has joined #zig
zags has quit [Ping timeout: 264 seconds]
shadeops has joined #zig
Techcable_ is now known as Techcable
m4r35n357 has quit [Ping timeout: 245 seconds]
m4r35n357 has joined #zig
powerofzero has quit [Remote host closed the connection]
powerofzero has joined #zig
cole-h has joined #zig
craigo has quit [Ping timeout: 245 seconds]
nvmd has joined #zig
dyeplexer has quit [Remote host closed the connection]
tnorth has quit [Ping timeout: 260 seconds]
filpAM has joined #zig
filpAM has left #zig [#zig]
waleee-cl has joined #zig
txdv has joined #zig
<txdv> `Vector2 ballPosition = { (float)screenWidth/2, (float)screenHeight/2 };` how do I do this in zig?
<ikskuh> const Vector2 = struct { x: f32, y: f32 };
<ikskuh> var ballPosition = Vector2 { .x = @intToFloat(f32,screenWidth)/2, .y = @intToFloat(f32, screenHeight)/2 };
<txdv> `.x =` thanks!
<txdv> raylib + zig is so simple, easy and fun to use, it should be on the zig playground as one of the default examples
zags_ has quit [Ping timeout: 276 seconds]
notzmv has quit [Ping timeout: 260 seconds]
ur5us_ has joined #zig
<andrewrk> what zig playground are you referring to?
<andrewrk> mikdusan, thanks for looking into zig-bootstrap/macos/CI stuff. hmm so did we regress with llvm12? I think we do use zig-bootstrap for macos CI right now
txdv has quit [Quit: Connection closed]
ur5us_ has quit [Remote host closed the connection]
ur5us_ has joined #zig
<andrewrk> ah right, so what we do is use `zig cc` and `zig c++` only, to build zig, on macos. I think that will still work fine with llvm12, right?
sord937 has quit [Quit: sord937]
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
powerofzero has quit [Remote host closed the connection]
powerofzero has joined #zig
Akuli has left #zig ["Leaving"]
zags has joined #zig
Akuli has joined #zig
<s-ol> how does package resolution work for @import()?
Akuli has quit [Quit: Leaving]
<s-ol> ah, i found build.Pkg.dependencies, which does what I need :)
notzmv has joined #zig
dddddd has quit [Ping timeout: 256 seconds]
dddddd has joined #zig
xackus has joined #zig
xackus_ has quit [Ping timeout: 264 seconds]
texno has quit [Ping timeout: 246 seconds]
tane has quit [Quit: Leaving]
<Raito_Bezarius> can we deep initialize a struct?
<Raito_Bezarius> inst = A { .subinst = B { .x = 0, .y = 1 } }
<Raito_Bezarius> something like that
<Raito_Bezarius> nevermind, I was doing something wrong
ur5us_ has quit [Ping timeout: 264 seconds]
powerofzero has quit [Ping timeout: 260 seconds]