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/
adamkowalski has joined #zig
<via> i built zig from source, and ran into a compiler crash that produces no real traceback, just addresses. how do i build in a way that has names?
adamkowalski has quit [Quit: Lost terminal]
_whitelogger has joined #zig
doublex has quit [Ping timeout: 260 seconds]
<Snektron> Did you build as release? because otherwise (in debug) it should have names
<Snektron> (release is enabled with -DCMAKE_BUILD_TYPE=Release)
<via> i even explicitly used Debug
doublex has joined #zig
lunamn_ has joined #zig
swoogan has joined #zig
lunamn has quit [Ping timeout: 265 seconds]
<Snektron> Weird, though to be honest im not sure wether it works on my own build
mahmudov has quit [Read error: No route to host]
mahmudov has joined #zig
lukeholder has joined #zig
mahmudov has quit [Read error: No route to host]
mahmudov has joined #zig
lukeholder has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
lukeholder has joined #zig
lukeholder has quit [Ping timeout: 258 seconds]
schme245 has joined #zig
_whitelogger has joined #zig
_whitelogger has joined #zig
swoogan has quit [Ping timeout: 260 seconds]
dddddd has quit [Ping timeout: 260 seconds]
henbr has quit [Quit: WeeChat 2.4]
plumm has joined #zig
<plumm> andrewrk: any chance we could merge that typeof hack fix? or is there something in the way
<plumm> tysm
<andrewrk> np
henbr has joined #zig
schme245 has joined #zig
lunamn_ has quit [Ping timeout: 268 seconds]
lunamn has joined #zig
neceve has joined #zig
<Dominic[m]> Okay, I clearly don't understand zig async at all :D I'm reading https://github.com/andrewrk/zig-async-demo/blob/master/sieve/sieve.zig and I'm not sure if https://github.com/andrewrk/zig-async-demo/blob/master/sieve/sieve.zig#L46 returns immediately or not?
<Dominic[m]> As a continuation of my confusion, http://sprunge.us/1jiwH7 does not have any mix of A/B for me. But if A were backgrounded that should be the case I would think?
lunamn has quit [Ping timeout: 268 seconds]
lunamn has joined #zig
<schme245> how can I do conditionals in my code that depend on the release mode?
<schme245> I remember there's a builtin for that somewhere but I can't find it
<schme245> found it, `builtin.mode`! but how come that variable is not defined anywhere in builtin.zig? 🤔
<mq32> schme245: there's "zig builtin" and "std.builtin"
<mq32> zig builtin delivers you with the runtime values
<schme245> gotcha! I guess that is implemented somewhere in the C++ compiler then?
<mq32> yeah, it is emitted for every build
<schme245> andrewrk: this commit makes me so happy, Zig comptime is just amazing! :D https://github.com/schmee/zig-crypto/commit/428b8c04c40b9ce582d5d6c543705401059a409c
lunamn has quit [Ping timeout: 258 seconds]
lunamn has joined #zig
<daurnimator> andrewrk: `--color off` turning off using all terminal escape codes seems like bad naming
dddddd has joined #zig
mahmudov has quit [Ping timeout: 260 seconds]
_whitelogger has joined #zig
<traviss> `if (new_size <= old_mem.len and new_align <= new_size) {`
<traviss> should be new_align <= new_align ?
<traviss> *new_align <= old_align
<Dominic[m]> Following to my question above about async, https://github.com/ziglang/zig/issues/3557 explains why my example doesn't switch I think.
<Dominic[m]> It would be nice to have some indication in the docs when a function is async-capable.
<daurnimator> Dominic[m]: async/await themselves are cooperative
<daurnimator> Dominic[m]: unless you (or code you call) calls `suspend`, then its the same as a non-async function
<Dominic[m]> daurnimator: So that would imply somewhere in https://github.com/andrewrk/zig-async-demo/blob/master/sieve/sieve.zig#L12-L17 there's a suspend. But I have no idea where.
<Dominic[m]> (and no idea how to find out)
<daurnimator> well I see one function in there; guess :)
<Dominic[m]> It did cross my mind that loop iterations might "implicitly" suspend or something like that, in order to provide a way for the loop to pause.
<Dominic[m]> It does seem like async is fairly undocumented outside of the places you can manually do it yourself. Reading the source of the zig os/fs/system stuff has been useful.
<Dominic[m]> https://lobste.rs/s/oi147v/async_programming_go_vs_zig_factorial#c_pgozah I think I misinterpreted this a little to mean "The std lib is already async and no work is needed to make it async"
_whitelogger has joined #zig
nofmal has joined #zig
<nofmal> hello, i was wondering if there's any plan for anonymous function?
bilebucket has joined #zig
<dingenskirchen> currently you can create an anonymous struct with a method, then refer to that using the variable the struct's bound to
<dingenskirchen> const fun = struct { fn call(i: i32) void { std.debug.warn("{}", i); } }.call; fun(42)
<dingenskirchen> should work
<dingenskirchen> …apart from me forgetting the list literal around the warn arguments :p
Akuli has joined #zig
<nofmal> dingenskirchen: thanks for the tip
<nofmal> i was using labeled block to return different values, hoping it'd somehow work like an anon function, but nope
nofmal has quit [Ping timeout: 260 seconds]
decentpenguin has joined #zig
decentpenguin has quit [Client Quit]
<Snektron> hm
<Snektron> Creating an ArrayList with T a union(enum) i get a broken module
<Dominic[m]> Can I get a clue as to why this segfaults? I tried gdb but the 0x0 wasn't very useful.
mahmudov has joined #zig
<Dominic[m]> http://sprunge.us/MxaaBO was this, figured it out. It's because the main exits. So I need to wait for the global loop to be empty.
nimar has joined #zig
<via> is there a way to get `zig test` to only try compiling/running whats in `test` blocks? it seems to also be trying to compile exported functions
<via> use case is trying to write a few unit tests in a file that works with lots of c code on an embedded target, the full source won't compile/link on the hosted target
lunamn has quit [Ping timeout: 258 seconds]
lunamn has joined #zig
schme245 has quit [Remote host closed the connection]
marmotini_ has joined #zig
marmotini_ has quit [Read error: Connection reset by peer]
marmotini_ has joined #zig
schme245 has joined #zig
<via> i am really struggling to get a C []char* style array of strings to work when calling a C function
<Snektron> via, you could extract the non-specific code to a different file and only run the tests in that file
<via> i've tried a variety of things, but in gdb most of the parameters to that C function are mangled. the usb_strings symbol appears to be right in the final executable
<via> e.g. it looks like just a list of addresses to what looks like the right strings
<via> but yeah, strings is getting passed in as a null ptr
<Snektron> i think usb_strigns should be a [_][*:0]const u8
<andrewrk> Dominic[m], the evented-based file system I/O bitrotted with the new async/await implementation, and is ready for a rewrite now that new async/await is here
<via> Snektron: i've tried that, but even if the data structure is wrong, its that a null is getting passed to the function instead of the address of usb_strings
<andrewrk> Dominic[m], well, not a rewrite, just test coverage
<via> its almost like there's a calling convention issue, but i've built the c library with the same target with clang
schme245 has quit [Remote host closed the connection]
DrDeano has joined #zig
<DrDeano> I am trying to run my zig build test, but im getting a integer overflow in the std.os.linux.vdso.lookup
<andrewrk> DrDeano, WSL?
<DrDeano> yes
<DrDeano> i see
<DrDeano> thank :)
schme245 has joined #zig
marmotini_ has quit [Remote host closed the connection]
alva has joined #zig
<fengb> andrewrk: I'm running into issues where I recursively call format() https://github.com/fengb/zig/blob/15bb1234275af5425232b8a9c122bd81e6991161/lib/std/fmtgen.zig#L1454
<fengb> Since this isn't "true" recursion as it's a different generic type, this should theoretically be okay
<Dominic[m]> Where last_vol is a ?u32, are there plans to make something .like this compile? `if (last_vol == null or new_vol != last_vol) {`
<Dominic[m]> Looks like last_vol.? is the trick :)
<andrewrk> fengb, yes
<andrewrk> agreed
<fengb> The codepath is pretty complex so I haven't gotten a reduced case yet :/
TheLemonMan has joined #zig
<TheLemonMan> yo andrewrk, what do you think about letting the warnings from clang bubble up to the Zig side?
<andrewrk> TheLemonMan, the "unused args" ones from assembly?
<TheLemonMan> the ones from cimport/translate-c
bilebucket has quit [Quit: WeeChat 2.7]
<andrewrk> ok so clang is giving us warnings, that is information we need to communicate to the programmer
<andrewrk> I don't want clang to be in charge of stderr/stdout however
<andrewrk> one thing we can do is put them inline with the translated code as comments
<andrewrk> the problem I have with warnings is that if you repeat an operation, you don't get warnings the second time, and now you have people clearing the cache to get warnings again
DrDeano has quit [Remote host closed the connection]
<andrewrk> warnings are inherently incompatible with incremental compilation
<TheLemonMan> yeah it's a bit of a mess if you take everything into account
<andrewrk> one idea might be to have warnings prevent a c object from getting cached...
<andrewrk> if anyone wants a fun contributor friendly task, try adding as much test coverage to translate-c as you can with the new run-translated-c test harness
<andrewrk> TheLemonMan, I'll work on merging callconv now
ur5us has joined #zig
euandreh has joined #zig
schme245 has quit [Remote host closed the connection]
<TheLemonMan> oh that's neat, it should be pretty easy to review/rebase
<TheLemonMan> there's also #3955 if you're after some lightweight PRs :)
<andrewrk> looking
<andrewrk> oh I wanted to look into this a little bit, there were some more edge cases I wanted to consider
schme245 has joined #zig
Akuli has quit [Quit: Leaving]
doublex has quit [Ping timeout: 258 seconds]
<Snektron> Dominic: , you can achieve that with `if (last_vol == null or new_vol != last_vol.?)`
<Snektron> Assumed new_vol is not optional
ky0ko17 has joined #zig
ky0ko has quit [Disconnected by services]
ky0ko17 is now known as ky0ko
ltriant has joined #zig
<Dominic[m]> It is not, thanks!
<Dominic[m]> I say this every week I'm here, but I have a lot of fun using Zig. Thank you!
<andrewrk> glad you can get past the instability & churn :)
doublex has joined #zig
<via> andrewrk: well, i did write a test for the packed struct thing that verified the sizeof output, but ran into https://github.com/ziglang/zig/issues/1481. for now i guess just compiling/running will have to do
ltriant has quit [Read error: Connection reset by peer]
ltriant has joined #zig
watzon has joined #zig
watzon has left #zig ["ERC (IRC client for Emacs 26.3)"]
<andrewrk> via, ah, yes that C ABI issue is annoying
<andrewrk> lunamn, your dns PR is almost next in the queue :)
doublex has quit [Ping timeout: 268 seconds]
doublex has joined #zig
<Snektron> if a function taking var receives an anonymous array literal
<Snektron> Is it a struct or an array?
neceve has quit [Remote host closed the connection]
<hryx> Snektron: I think it just depends on how the var parameter is used inside the function
<andrewrk> Snektron, the type of an anonymous list literal is a struct
<andrewrk> well, it's a tuple. a tuple is a struct but also lets you do element indexing and `.len` field
<Snektron> Alright, thanks
<andrewrk> according to type info, it will be a struct with a "is_tuple: bool" set to true
<andrewrk> or equivalent
<hryx> oh, so then .{1, 2, 3} is just a struct with fields called @"1", @"2", and @"3" ?
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<andrewrk> in this case the fields are {comptime @"0": comptime_int = 1, comptime @"1": comptime_int = 2, comptime @"2": comptime_int = 3}
<andrewrk> this is a zero bit type
<andrewrk> and the value of the fields cannot be changed
TheLemonMan has joined #zig
lukeholder has joined #zig
<TheLemonMan> andrewrk, can you merge #4078? I possibly need it to fix some problems uncovered by the new testing harness
lukehold_ has joined #zig
<andrewrk> done
<TheLemonMan> thank you, juggling all those PRs open is getting quite confusing heh
<andrewrk> ha yeah I'll bet. you've been producing them faster than I can merge them
<andrewrk> I wanted to get that new test harness done
lukeholder has quit [Ping timeout: 260 seconds]
<andrewrk> focusing on callconv next
swoogan has joined #zig
lukehold_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
lukeholder has joined #zig
lukeholder has quit [Client Quit]
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<daurnimator> andrewrk: I think that tuple->struct conversion is a weird place to introduce int-to-string conversion.... very javascript-esque
<plumm> daurnimator: example?
<daurnimator> `mytuple[someinteger]` --> this essentially has to do `@field(mytuple, intToString(someinteger))`
<Snektron> the field name is not related to the value though
<daurnimator> Snektron: ??
<Snektron> there is no conversion in the field names, its just a placeholder name as far as i understand
<andrewrk> that's correct
lukeholder has joined #zig
ky0ko has quit [Ping timeout: 265 seconds]