ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
v1zix has quit [Ping timeout: 256 seconds]
porky11 has quit [Ping timeout: 268 seconds]
wilsonk has quit [Read error: No route to host]
<benjikun> andrewrk: Whatcha workin on?
<andrewrk> benjikun, proof of concept of making zig's stack traces work in freestanding mode
<benjikun> I see, neat
steveno has joined #zig
steveno has quit [Quit: Leaving]
reductum has joined #zig
reductum has quit [Quit: WeeChat 2.3]
wilsonk has joined #zig
tiehuis has joined #zig
<tiehuis> found the separate loop initializers tripped me up in the advent of code solution today
<tiehuis> accidently put the inner `var j: usize = 0` on the outer level which stumped me for 5 minutes
<andrewrk> interesting
<IntoxicatedHippo> I think allowing a third expression on while loops so they act like C style for loops would be useful.
<IntoxicatedHippo> Nevermind, I looked through the issues and found this: https://github.com/ziglang/zig/issues/472#issuecomment-330563545
<IntoxicatedHippo> Maybe an example like that should be in the docs.
reductum has joined #zig
<andrewrk> tiehuis, you are unstoppable
<reductum> I'm amazed at how quickly people are doing these advent of code puzzles.
<reductum> For now, functions can't return multiple values. Is that correct?
<reductum> So either structs or mutable pointer args should be used to get multiple results from a function call.
<andrewrk> reductum, correct
<reductum> Got it. Thanks.
williamcol3 has joined #zig
williamcol3 has quit []
williamcol3 has joined #zig
IntoxicatedHippo has quit [Remote host closed the connection]
IntoxicatedHippo has joined #zig
diltsman has quit [Ping timeout: 256 seconds]
Hejsil has joined #zig
<Hejsil> Curse you, timezones!
<tiehuis> i've got a good 6pm start on these puzzles so that turns out well for me
<tiehuis> that being said, the fastest people are pretty fast, best rank so far for me was yesterday with 218
<tiehuis> i also prefer restructing the input into static data using vim macros first too which is probably a slow method
<tiehuis> the scanf-like thing you were working on Hejsil would be cool to see
<Hejsil> Oooh ye, i did make something like that. Time to use it!
<IntoxicatedHippo> On the other hand, I wasted 10 minutes because this buffer was too small, so doing it with macros is sometimes faster :P https://github.com/liampwll/advent-of-code-2018/blob/master/3.zig#L9
<tiehuis> was thinking it'd be helpful for todays question
<reductum> Yeah I'm wading through just parsing everything. I've never gotten much practice parsing things, so I'm pretty slow at it, even with simple input like this.
<reductum> Good practice, though!
<reductum> Zig's `test` feature is just lovely.
<andrewrk> tiehuis, your code is just magnificent
<andrewrk> makes me question my decision to parse the input text line by line
<andrewrk> I didn't even figure out how to get the ** feature to work, and I &@#*&@in coded it!
<tiehuis> thanks, yeah unfortunately parsing manually is pretty ugly
IntoxicatedHippo has quit [Remote host closed the connection]
IntoxicatedHippo has joined #zig
<reductum> Hmmm. I'm getting a compile-time error message for a situation that looks equivalent to an example from the 0.3.0 docs.
<reductum> var rects = []Rect{Rect.ini(0, 0, 0, 0)} ** 1000;
<reductum> Where Rect.init just returns a Rect struct.
<reductum> This looks just like the "call a function to initialize an array" section here: https://ziglang.org/documentation/0.3.0/#Arrays
<reductum> But I get "error: unable to evaluate constant expression"
basro has quit [Disconnected by services]
basro_ has joined #zig
basro_ is now known as basro
<Hejsil> After solving the wrong problem, day 3,1 is done! https://github.com/Hejsil/advent-of-code-2018/blob/master/src/day3_1.zig
<Hejsil> my "scan" impl was really useful for parsing
<reductum> Here's a repro: https://godbolt.org/z/UlGVlh
<reductum> It's just a subset of the array example code copied and pasted.
<Hejsil> This fixes it: https://godbolt.org/z/Jdcmh6
<Hejsil> Though, ** should really make the right hand side a comptime context, so you dont need this
<reductum> Hejsil: Thank you! I haven't totally figured out the rules around comptime.
<reductum> Oddly, when I paste the entire documentation snippet into godbolt, it successfully compiles: https://godbolt.org/z/ph91y9
<reductum> I wonder why the subset fails when the full set succeeds.
<Hejsil> Because the var is global
<Hejsil> And globals init expr are implicitly comptime :)
<reductum> Ahhhhh.
<williamcol3> Hey, is there a way to specify the branches of a switch statement programmatically at comptime?
IntoxicatedHippo has quit [Quit: Leaving]
<Hejsil> williamcol3, Not anything semantically, but using inline loops, code generation can be the same in release mode: https://godbolt.org/z/wuCbjz
<williamcol3> Hejsil, well look at that. Way to go LLVM.
<williamcol3> Thanks.
williamcol3 has quit [Ping timeout: 246 seconds]
tiehuis has quit [Quit: WeeChat 2.3]
forgot-password has joined #zig
forgot-password has quit [Ping timeout: 250 seconds]
IntoxicatedHippo has joined #zig
IntoxicatedHippo has quit [Remote host closed the connection]
<j`ey> all these advent solutions may push zig over the number of repositories to get zig to have syntax hilighting on github
<reductum> j`ey: I think it already happened. Github approved it.
<j`ey> ah cool
<j`ey> reductum: btw you might want to look at @embedFile
<reductum> Yeah I just found out about that today! It's super cool. I decided to just paste the array into the source, though, to keep everything self contained.
<reductum> Looking forward to reading everyone else's solutions tomorrow and learning how to do things properly in zig.
<reductum> It's 03:00 here. G'night, all
reductum has quit [Quit: WeeChat 2.3]
Hejsil has quit [Ping timeout: 256 seconds]
_whitelogger has joined #zig
wootehfoot has joined #zig
forgot-password has joined #zig
forgot-password has quit [Ping timeout: 250 seconds]
<sjums> Dear zig users. Today I made my first struct and also got a much better understanding of iterators. Today was a good day! 🙏
<j`ey> sjums: you should give andrewrk the code that you had the weird behaviour with
<sjums> I haven't looked into it, but I have a hunch that I might have freed some memory and kept reading from it
<sjums> Am on mobile, so can't throw code bits around right now :)
<j`ey> ah, that might cause a problem :P
<sjums> I initialized an arrraylist in a function, followed by a 'defer list.deinit()' and then returned the list to user later in my code
<sjums> I guess that creates problems 😇
<j`ey> sounds like it
porky11 has joined #zig
steveno has joined #zig
moo has joined #zig
wootehfoot has quit [Ping timeout: 250 seconds]
forgot-password has joined #zig
<sjums> how do I initialize a [2][26]u8 array to 0's ?
steveno has quit [Ping timeout: 250 seconds]
<MajorLag> var x = [][26]u8{[]u8{0} ** 26} ** 2;
<MajorLag> another way: `var x: [2][26]u8 = undefined; for(std.meta.asBytes(&x)) |*b| b.* = 0;`
unique_id has joined #zig
<unique_id> MajorLag: It's std.mem.asBytes :)
<MajorLag> yes, yes it is.
<MajorLag> I originally put it in meta and keep forgetting that we decided to move it.
<MajorLag> I make this mistake in my own code almost every time.
<MajorLag> habits, you know.
robbym has joined #zig
Zaab1t has joined #zig
steveno has joined #zig
<sjums> thanks Mr. Lag ! (:
<sjums> thanks Mr. Lag ! (:
unique_id has quit [Remote host closed the connection]
forgot-password has quit [Read error: Connection reset by peer]
forgot-password has joined #zig
forgot-password has quit [Ping timeout: 250 seconds]
<sjums> looking for C's sprintf, is fmt.bufPrint the way to go?
<sjums> What's the difference between the input buffers value and the returned value?
Hejsil has joined #zig
<Hejsil> sjums, the return slice is the subset of the input slice that was written too
<sjums> so if my buffer is 1000 u8's and there's only written 42 bytes to it, the returned value is a slice of those 42 u8's
<MajorLag> yes
<sjums> So the first AoC puzzle took me ~6 hours in zig
<sjums> Today I did day 3 part 1 in around one!
<sjums> Also currently watching andrew on YouTube #goingdeepintothecode
steveno has quit [Ping timeout: 252 seconds]
reductum has joined #zig
Hejsil has quit [Quit: Page closed]
<daurnimator> Does zig have an easy way to create a anon struct and initialise it?
<daurnimator> or do we have to: struct { foo:u32, bar:u32 } { .foo = 42, .bar = 100 }
<andrewrk> daurnimator, no but there is a proposal for it
williamcol3 has joined #zig
Zaab1t has quit [Quit: bye bye friends]
williamcol3 has quit [Ping timeout: 245 seconds]
reductum has quit [Quit: WeeChat 2.3]
steveno has joined #zig
moo has quit [Read error: Connection reset by peer]
steveno has quit [Ping timeout: 268 seconds]