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/
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 246 seconds]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 246 seconds]
<daurnimator> shachaf: no :( https://github.com/ziglang/zig/issues/2647 is a proposal to fix that. I see it got bumped to 0.6.0
avoidr has quit [Remote host closed the connection]
marijnfs has joined #zig
marijnfs__ has quit [Ping timeout: 246 seconds]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
_whitelogger has joined #zig
kristoff_it has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
<fengb> Is there a quick way to convert numbers to []u8 with fixed endianness?
kristoff_it has quit [Ping timeout: 268 seconds]
<andrewrk> fengb, std.mem.readIntSlice
<andrewrk> or rather std.mem.writeIntSlice
<fengb> Awesome, thanks!
<diltsman> On Windows, does Zig compile for 64-bit?
<andrewrk> not sure what you're asking
<diltsman> When I build with VC++ I have to choose 32-bit or 64-bit target.
<diltsman> They build against different sets of Windows libraries.
<andrewrk> if you don't specify a target, zig chooses the native target. you can use the -target parameter to choose a different target, not only including 32-bit windows but including other operating systems and architectures. the windows 32-bit target is a Tier 2 supported target
<diltsman> I assume, then, that it will default to a 64-bit build on 64-bit Windows.
<andrewrk> that's right
<diltsman> Any idea why the Zig standard library for Windows uses the W function variants instead of the A function variants?
<andrewrk> the A variants depend on global operating system user-configurable state
<diltsman> Good reason.
<andrewrk> and they have more limitations than the W variants. for example the number of bytes accepted in a file path
<fengb> random.int(f32) should probably throw a type error
<andrewrk> agreed
<daurnimator> diltsman: on windows you should always use W variants. the A functions are buggy userspace wrappers
<diltsman> Good to know. Now to look how the UTF8 strings are converted to UTF16. I'm sure that the library code will be useful.
<daurnimator> diltsman: don't forget that windows isn't UTF16, it's UCS-2
<daurnimator> diltsman: all lies
<diltsman> UGH! Incorrect documentation is worse than no documentation.
<fengb> They're mostly compatible for western character sets :P
<daurnimator> diltsman: my second link there links to https://googleprojectzero.blogspot.com/2016/02/the-definitive-guide-on-win32-to-nt.html which is what you should really read to understand windows paths
<fengb> wtf-8 lol
<daurnimator> andrewrk: you around?
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 244 seconds]
<daurnimator> Anyone around to help me with some atomic problems?
<karrick> I don’t know Zig we’ll but I know atomic stuff
<karrick> Is this what we were going thru pst night?
<daurnimator> karrick: got a preferred way I can share my screen with you?
<karrick> Open to suggestions
<karrick> How do you normally do it?
<daurnimator> karrick: see PM
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 272 seconds]
_whitelogger has joined #zig
<daurnimator> karrick: FYI I just pushed the problem code to https://github.com/ziglang/zig/pull/3083/files#diff-7f795abd6e7e15a724598fc0a0d25c91R512
<daurnimator> (in case you want to play)
<karrick> Thanks. I’m busy educating myself.
<karrick> Trying to catch up with you... :)
_whitelogger has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 244 seconds]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
wilsonk has joined #zig
THFKA4 has quit [Ping timeout: 250 seconds]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 272 seconds]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 246 seconds]
_whitelogger has joined #zig
kristoff_it has joined #zig
_whitelogger has joined #zig
kristoff_it has quit [Ping timeout: 246 seconds]
wootehfoot has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 244 seconds]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
moo has joined #zig
wootehfoot has quit [Ping timeout: 248 seconds]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 272 seconds]
noonien has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 272 seconds]
NI33_ has quit [Read error: Connection reset by peer]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 246 seconds]
<strmpnk> I've been thinking about the async/await design for a bit since Thursday's update.
<strmpnk> Is there a way to "race" multiple async calls/frames and return the first to return a value or fail?
<strmpnk> It seems like the await mechanism will prevent others from being awaited, which prevents parallelism on the return path.
<strmpnk> The "all awaits complete" semantics certainly makes errdefer semantics easier at least (re: cancellation was also an interesting problem).
<strmpnk> I don't think most code will care but certain kinds of I/O heavy work will want to avoid false sequencing, which means the awaiters will all need to have some kind of awareness of the suspend/resume scheduling code to achieve this.
<fengb> I think std.event.Channel is for this usecase: https://github.com/ziglang/zig/blob/master/std/event/channel.zig#L118
<strmpnk> Yeah, that does help, though it's unclear where the dangling await would end up.
<strmpnk> I guess the channel could be consumed and a separate thread or stage in processing could loop to await frames.
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
FireFox317 has joined #zig
<FireFox317> It seems like the tests for MacOS are stuck in std.event.Channel. It causes the MacOS CI to timeout after 6 hours
<diltsman> Why is "[*c]c_void" a problem? I see that the standard library uses "*c_void".
<diltsman> I assume that it has something to do with the union of behaviors of "*T" and "[*]T".
<andrewrk> FireFox317, should be fixed now. the std lib event loop code is still considered "experimental". After I'm convinced it's going in a stable direction I'll be a lot more careful about breakage
<fengb> diltsman: yeah [*] means it’s unknown whether it’s single or array.
<fengb> You shouldn’t design an API like that. It’s only for translating C, where we cannot know without reading the docs
<andrewrk> standard library usage of *c_void is a smell
<fengb> Oops, [*c] means unknown
<andrewrk> [*] means it points to an unknown number of items
<andrewrk> [*c] means it's unknown, but the API might still require using the pointer as a single item. and since the API is auto-translated, fixing the API to use [*] or * is not possible
<andrewrk> [*] also means not-null. but [*c] pointers can be null, but they allow treating it as non-null with out compiler type safety (runtime safety instead)
<andrewrk> if we didn't have C translation, we wouldn't have [*c] pointer types
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 268 seconds]
FireFox317 has quit [Remote host closed the connection]
return0e has quit [Ping timeout: 248 seconds]
return0e has joined #zig
laaron has joined #zig
avoidr has joined #zig
porky11 has joined #zig
avoidr has quit [Quit: leaving]
avoidr has joined #zig
johnLate has quit [Ping timeout: 245 seconds]
johnLate has joined #zig
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #zig
waleee-cl has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 248 seconds]
andersfr has joined #zig
andersfr has quit [Client Quit]
<diltsman> Me struggling to make the logical transition from C and C++: Is there some way to have an allocated array that is automagically collected when the array goes out of scope? Something like C++'s std::unique_ptr. My thought is that something vaguely like it is going to be possible, but it will have different syntax and semantics.
<tav> does anyone know if there's a vdom implementation in zig?
<tav> if not, I think I'll start working on one
<nrdmn> diltsman: the language zig doesn't have the concept of dynamic allocation and the stack works the same as in C and C++
<diltsman> That was my thought. So things have to be done through allocator types. Which means that you can defer the deallocation, but there is no way to transfer the ownership up a level of the stack once you have defered.
<nrdmn> correct
rjtobin has joined #zig
<diltsman> Is there a way to specify a set of flags that can be ored together to create a compound value but cannot be ored without any values outside of those flags? The best that I can see is to use constants at the file scope and just be careful to use just the correct ones.
marijnfs_ has joined #zig
<nrdmn> if you want to use an integer for your flags set and your flags are contiguous, you can use an integer that is exactly the width of your amount of flags
porky11 has quit [Ping timeout: 250 seconds]
<nrdmn> otherwise you can use a packed struct of bools and switch them on and off individually
<nrdmn> or u1, I'm not sure if bools are actually 1 bit when packed
<diltsman> 3 non-adjacent bits in the 32-bit integer.
marijnfs has quit [Ping timeout: 245 seconds]
kristoff_it has joined #zig
<andrewrk> tav, I'm fairly certain there is not
<andrewrk> nrdmn, yes bools are 1 bit in packed structs
kristoff_it has quit [Ping timeout: 245 seconds]
vexu has joined #zig
<mikdusan> diltsman: a basic attempt at a userland unique ref: https://gist.github.com/mikdusan/33a04b940bf25287025a9503bf18ade9
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 258 seconds]
vexu has quit [Quit: WeeChat 2.5]
<nrdmn> has anyone here successfully built parser combinators in zig?
curtisf has joined #zig
<curtisf> I've made some parser combinators, but they currently cause the compiler to crash when you use them with recursive structs
<curtisf> There's also a lot more ceremony than I'd like. It might be a bit better after we can create new struct types at compile time
<andrewrk> the issue for that is https://github.com/ziglang/zig/issues/383
<andrewrk> it's more of a design & usage patterns question than one of implementation
<nrdmn> curtisf: I got to that point too
<curtisf> yup! the compiler crash is the more pressing thing to me
<andrewrk> oh I see, do you have an issue open for it?
<curtisf> yep
<nrdmn> the issue is that they're evaluated at compile time
<curtisf> Yes
<andrewrk> noted
<curtisf> You can mostly work-around the lack of new structs, because you can generated structs with a `fn get(self: Self, comptime fieldname: []const u8)`, but I didn't do that for my library yet
<curtisf> nrdmm: If you want to compare my implementation (or give feedback, because it is pretty rough), it's here: https://github.com/CurtisFenner/zsmol/blob/master/src/parser.zig
<curtisf> oo I didn't see that 1315 for `@unionInit` was closed!
<andrewrk> oh yeah, that's done and working now. it even does result locations correctly
<andrewrk> 0.5.0 release notes is going to be a big document :)
<andrewrk> it will realistically take me upwards of a week just to draft those notes
<curtisf> it's a very long list of issues tagged with 0.5.0. Is it really going to be done in september?
<andrewrk> most of the issues will be postponed. but I will at least look at each and every one before then and consider what to do with it
<andrewrk> each milestone has a description like this: "Accept and resolve these issues, reject, or postpone them before releasing 0.5.0."
<curtisf> That's what I figured. I'm very happy with zig so far (other than the number of crashes I've hit) and it looks like it's growing up nicely
<andrewrk> on https://github.com/ziglang/zig/milestones?state=closed you can see that 0.3.0 and 0.4.0 each had about 270 issues resolved in them. 0.5.0 is at 167 currently
<andrewrk> I feel you on the crashes. Towards the end of a release cycle, I focus on stability and bug fixes. So we should start to see those crashes getting fixed over the next month and a half
<andrewrk> right now we're at peak instability - just finished 2 major reworkings of zig's innards - result location semantics & async/await rewrite
kristoff_it has joined #zig
<andrewrk> so it can only get better from here
<andrewrk> also there aren't many big breaking changes left to do
<andrewrk> we're getting close to the language's final syntax / semantics
kristoff_it has quit [Ping timeout: 244 seconds]
<andrewrk> btw, the winner of the mascot poll is Ziguana: https://i.imgur.com/OMhlc8A.png
<curtisf> yes!
<curtisf> the poll was a little unfair, the others didn't get puns
<andrewrk> tbh it was rigged, if ziguana didn't win, I was just going to ignore everybody's preference
<andrewrk> >:-]
keithdc has joined #zig
<nrdmn> curtisf: I tried to build something much simpler that doesn't require an allocator: https://github.com/nrdmn/zpc/blob/foo/main.zig
<curtisf> how do you parse recursive structures without an allocator?
<andrewrk> once zig has unsafe recursion prevention, you won't be able to
<nrdmn> to prevent my code from being run at compile time, I tried to use an interface for the structs returned from the parsers, but I became too tired to continue to work
<hryx> andrewrk: I just saw your last stream. Congratulations on the huge merge!
<andrewrk> thanks hryx :)
<hryx> sad I missed the poll, but I obviously would have chosen the reptile anyway
<andrewrk> yeah the name has to be a pun on the language name and it has to be something not already dressed up, so that people can dress it up in cute ways. clearly the other 2 are disqualified
<hryx> heh. Is the artist already chosen?
marler8997 has joined #zig
<marler8997> I'm trying to use zig like a regular C compiler where it recognizes C-command-line arguments and other build tools can use it like a c-compiler.
<scientes> marler8997, zig cc does that....
<marler8997> but it doesn't work like a normal C compiler
<marler8997> I can't just do "zig cc hello.c"
<scientes> oh hmm
<marler8997> so other build tools don't know how to use it
<scientes> i though it just calls clang
<andrewrk> marler8997, that doesn't exist currently. `zig cc` has no system awareness. it's unclear whether that will ever exist
<marler8997> I'm trying to use zig as the c-compiler to build other C projects using their build system
<marler8997> I could create a translation program, but wondering if any work/design exists for this already
<andrewrk> I understand the use case. I think it could be at least considered. can you open an issue?
<marler8997> sure thing
<andrewrk> idea being that it will act exactly like clang, except it will set up the linker & includes to use zig's libc, libunwind, etc
<marler8997> right
<andrewrk> which is what already happens with the higher level CLI
<andrewrk> but it's a different CLI than clang
<marler8997> yeah
Taslem has joined #zig
<marler8997> If that was supported, we could even use zig to build llvm :)
<andrewrk> hryx, somebody volunteered to draw one
<curtisf> Is there a trie or balanced tree map in the standard library that I've missed? also, is there a plain old FIFO queue?
<marler8997> to "draw one"?
<curtisf> to draw a ziguana
<fengb> The ziguana needs a space ship
Taslem has left #zig [#zig]
<andrewrk> curtisf, have you seen the file std/std.zig?
<andrewrk> I'm not sure what red black trees are but that might be related (std.rb). I believe TailQueue is a doubly linked list
<andrewrk> been meaning to change the namespacing, but std.atomic.Queue is a doubly linked list that is protected by a mutex to make it thread safe
<curtisf> ah, I missed "TailQueue", although I was hoping for a circular buffer. Didn't realize "rb" stood for "red black", that is it
fubd has joined #zig
<andrewrk> thanks marler8997
<marler8997> yeah
<fubd> are bound fns a thing yet?
<fubd> i.e., can i pass one to a function that takes a "fn() void" callback
<fubd> will they ever work that way?
keithdc has quit [Ping timeout: 245 seconds]
andersfr has joined #zig
andersfr has quit [Client Quit]
fubd has quit [Remote host closed the connection]
kristoff_it has joined #zig
<shachaf> andrewrk: On recursion: The "standard" way to handle stack frames is to just use an arena to allocate frames. I guess Zig calls this variant a FixedBufferAllocator (though I don't think the current implementation has frame support?).
<shachaf> It would sure be nice if platform ABIs just told you how big the stack is rather than expecting you to SEGV if you use too much.
<andrewrk> shachaf, you can use any allocator to put a frame in it
<andrewrk> in general we know how big the stack is - we get to decide that
<shachaf> Sure. I mean the standard stack behavior for non-async functions is effectively allocating frames in an arena.
<shachaf> You mean you know in the case of async functions or in general?
kristoff_it has quit [Ping timeout: 245 seconds]
<andrewrk> in general
<andrewrk> it's an option you pass to the linker that decides the stack size
<andrewrk> the challenge is knowing at compile time the upper bound that will ever be used
<shachaf> Ah, I was going to say something about bounded recursion but it looks like you have it all figured out. :-)
<shachaf> What's the linker option for stack size? My impression was that platforms leave this pretty vague.
<andrewrk> it's target-specific. here's where we set it for stage1 compiler for windows & mingw: https://github.com/ziglang/zig/blob/ea1734773ba9913e32318aba963cdcb9f51128d4/CMakeLists.txt#L514-L516