ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
<scientes> the only reason it can't be in the set at the same time is because we are using EPOLLONESHOT
<scientes> in which you have to re-arm the epollfd
<andrewrk> that's necessary so that only one thread from the pool receives the coroutine handle
<andrewrk> that's where the multiplexing happens
<scientes> so co-routines introduce that limitation
<andrewrk> what's the limitation? what alternative are you comparing it to?
<scientes> you can only do one event at a time for one fd
<scientes> oh, i guess that is the case anyways
<scientes> because of the way fds work
<scientes> yeah this co-routine stuff is really complicated
<scientes> i can think about threads, but havn't quite wrapped my mind around co-routines
<andrewrk> it gets complicated to implement, but once the pieces are in place, the API is easy to reason about
<andrewrk> I want to make it more explicit where the coroutine frame memory goes though
<scientes> I'm still more confortable with a go threading model, where everything feels like a thread
<andrewrk> it's suboptimal
<scientes> There is a leak where the `coroutine_handle` is never resumed, because it is no longer in the epoll set.
<andrewrk> in order for it to leave the epoll set it would have to get resumed, or the code removing it will cancel the coroutine
<scientes> I don't think you have it figured out either
<scientes> but i won't understand it until i understand await fully
<unique_id> ..
<scientes> i'm not there either
<unique_id> well I hope you guys figure it out. Maybe I'll save some of these chats to understand coroutines better myself :)
clownpriest has quit [Quit: clownpriest]
<andrewrk> I would recommend the docs instead: https://ziglang.org/documentation/master/#Coroutines
<scientes> yeah my lack of knowledge is distracting
clownpriest has joined #zig
<scientes> > This class is not thread safe.
<andrewrk> this is thread safe
<andrewrk> the docs on each functions tells if it is thread safe
noonien has quit [Quit: Connection closed for inactivity]
clownpriest has quit [Quit: clownpriest]
clownpriest has joined #zig
<andrewrk> hmm should we remove @maxValue? since it can be implemented in userland
<MajorLag> Makes sense to me.
<andrewrk> MajorLag, I think your second test on 906 is a bug
<MajorLag> And here I was pretty convinced it wouldn't be.
<MajorLag> Because a lot of the things I blamed on 906 went away when I started tagging functions as `comptime` at the callsite.
<andrewrk> yeah it fixes it if you put `comptime isSliceType(FieldType)`
<andrewrk> but it should work without that
<MajorLag> Interesting. I've taken to tagging all trait.zig calls comptime at the callsite due to issues like this. If this is a bug and it gets fixed maybe I can stop doing that. It'd make it a little nicer.
<MajorLag> yeah, that'd probably help. Even when I wrap the entire function body in a comptime block it isn't enough.
<andrewrk> I think I see the problem
<andrewrk> this is a really good test case
<andrewrk> ok so count is a comptime var right
<andrewrk> this means that every store to count must be a comptime known value, and every load from count must be to a comptime value
<andrewrk> however the expression `isSliceType(FieldType)` is a runtime known value
<andrewrk> and so when we do `if (isSliceType(FieldType)) count += 1`, there's a load and store with a comptime value *inside a runtime branch*
<andrewrk> this is unsound, so there should be a compile error for it, but there is not
<andrewrk> in other words we need to do count += 1 at comptime, but we're actually doing it at runtime. that should be impossible
<andrewrk> it actually fixes the test case if you remove `comptime` from `var count = usize(0)`
<MajorLag> I didn't think type was ever a thing that actually existed at runtime.
<andrewrk> it's not - FieldType is a comptime value
<andrewrk> but isSliceType returns a bool
clownpriest has quit [Quit: clownpriest]
<MajorLag> Which is effectively a constant. But if I understand what you're saying, then because optimization hasn't happend yet any code that is conditionally run based on that value still exists and is evaluated?
<MajorLag> At least, that's the problem in the first test case?
<andrewrk> correct
<andrewrk> imagine that every block of code is colored red for comptime or blue for runtime. count += 1 must happen in a red block, but it's happening in a blue block
<andrewrk> but if you remove `comptime` from `comptime var count ...` then it can happen in a red or blue block
<andrewrk> `inline` on a `for` turns the `for` from blue to red
<MajorLag> Ultimately it was the same issue then, which is my failure to understand that the return of an fn(type) is not necessarily red, even if `type` must be, which is why count is marked comptime. It just happened that I also stumbled on a legit bug.
<andrewrk> here's a simple example of that kidn of function: var global: usize = 0; fn foo(comptime T: type) { global += @sizeOf(T); }
<andrewrk> throw a correct return type and `return global` in there
clownpriest has joined #zig
clownpriest has quit [Quit: clownpriest]
clownpriest has joined #zig
clownpriest has quit [Client Quit]
clownpriest has joined #zig
clownpriest has quit [Client Quit]
clownpriest has joined #zig
clownpriest has quit [Client Quit]
clownpriest has joined #zig
clownpriest has quit [Client Quit]
clownpriest has joined #zig
clownpriest has quit [Client Quit]
clownpriest has joined #zig
reductum has joined #zig
_whitelogger has joined #zig
clownpriest has quit [Quit: clownpriest]
clownpriest has joined #zig
clownpriest has quit [Client Quit]
clownpriest has joined #zig
clownpriest has quit [Client Quit]
clownpriest has joined #zig
_whitelogger has joined #zig
<andrewrk> MajorLag, I think I changed my mind about whether this is a bug
dbandstra has quit [Quit: Leaving]
ManDeJan has quit [Ping timeout: 244 seconds]
reductum has quit [Quit: WeeChat 2.2]
ManDeJan has joined #zig
scientes has quit [Ping timeout: 276 seconds]
davr0s has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
bheads has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
noonien has joined #zig
davr0s has joined #zig
clownpriest has quit [Ping timeout: 272 seconds]
clownpriest has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
zyzzy has joined #zig
<zyzzy> Hey! I'm playing around with zig and have a problem to start with: https://pastebin.com/raw/P8PgHawx
<andrewrk> zyzzy, looks like you need to add --library c to your build command
<andrewrk> since you are depending on the c allocator
<zyzzy> Ah, I missed that. Thanks, that works.
<andrewrk> I think we can make that automatic in the future, or at least a direct error that tells you what you need to do
ManDeJan has quit [Remote host closed the connection]
jzelinskie has joined #zig
davr0s has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
wilsonk has quit [Read error: Connection reset by peer]
wilsonk has joined #zig
kristate has joined #zig
clownpri1 has joined #zig
clownpri2 has joined #zig
clownpriest has quit [Ping timeout: 252 seconds]
clownpri1 has quit [Ping timeout: 240 seconds]
davr0s has joined #zig
zyzzy has quit [Ping timeout: 252 seconds]
kristate has quit [Ping timeout: 245 seconds]
clownpri2 is now known as clownpriest
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
mahmudov has joined #zig
clownpri1 has joined #zig
clownpri1 has quit [Client Quit]
clownpriest has quit [Ping timeout: 252 seconds]
<MajorLag> andrewrk, if I understand your reponse in #906 correctly, then the fact that isSliceType returns a runtime value causes both branches to be analyzed, and because `count` is a comptime var `count += 1` takes effect when it is analyzed. If I replace `isSliceType` with `false`, however, I get the expected result of 0 since `false` is known to be constant during the analysis. If I replace the guts of `isSliceType` with `return false` the origi
<MajorLag> al behavior returns because the result of `isSliceType`, though known at compile time, is not known during the analysis of `countSliceMembers`. Is this a correct understanding?
<andrewrk> MajorLag, the first part is correct
<andrewrk> if you replace the guts of `isSliceType` with `return false` I don't think that changes anything
<MajorLag> Right, it behaves identically to the original test.
<andrewrk> because at the callsite of isSliceType, the result is a runtime value
<andrewrk> I'm going to experiment with a new compile error that would take effect for 906 and see if it breaks anything in std
clownpriest has joined #zig
<andrewrk> I'll turn my idea into a proposa
<andrewrk> MajorLag, this is similar to the concept of modifying global data at comptime
<andrewrk> which would be an argument in favor of making it an error
<andrewrk> ultimately, I think that if making it a compile error does not break any valid use cases, then I'm in favor of it
clownpri1 has joined #zig
clownpriest has quit [Ping timeout: 240 seconds]
<unique_id> I need to get myself a lock-free reader writer queue, single-producer, single-consumer. C or Zig. Or I could try converting a C++ one!
<unique_id> or just create a c interface for it..
<andrewrk> fixed size element buffer?
<unique_id> I think so
<andrewrk> lock free programming is incredibly difficult
<unique_id> yeah that's why I'm going to rely on other peoples solutions :)
<andrewrk> there's still a verification problem for other people's solutions though
<unique_id> it's for communicating between a 'control' thread and a 'render' (audio) thread
<unique_id> web audio API, which I'm porting to Zig. Using webkit/labsound code.
<unique_id> libsoundio at the bottom :)
<andrewrk> not to discourage you - I'm just observing that you're about to do something difficult
<unique_id> using a queue isn't difficult. here's one: https://github.com/cameron314/readerwriterqueue
<unique_id> this one is will known
<andrewrk> I think the bug fix I just pushed is going to make comptime programming in zig a lot easier for people
<unique_id> but c++ :(
<andrewrk> it would be pretty straightforward to translate that
<andrewrk> by hand, I mean
<unique_id> yeah I think I'll try that
clownpriest has joined #zig
clownpri1 has quit [Ping timeout: 252 seconds]
kristate has joined #zig
clownpriest has quit [Ping timeout: 252 seconds]
clownpriest has joined #zig
kristate has quit [Ping timeout: 260 seconds]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<andrewrk> llvm 7.0.0 got delayed by a week so here's the new zig 0.3.0 schedule: https://clbin.com/tgA5r
<andrewrk> anyone know a blake2b single file C implementation?
<andrewrk> nvm I found the reference impls
davr0s has joined #zig
<wink_> andrewrk: why is memdupe not named memdup, were you trying to trick someone?
<andrewrk> it's named after strdup
<andrewrk> that's subject to change before 1.0.0
<wink_> which isn't named strdupe, correct?
<wink_> Anyway, would you accept a rename now if I create a PR?
<wink_> I count 30 lines with dupe in it
clownpriest has quit [Quit: clownpriest]
clownpriest has joined #zig
clownpriest has quit [Client Quit]
clownpriest has joined #zig
wink_ has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
<andrewrk> let's wait and do a big batch of renames at once
<andrewrk> I'm not sure that dupe will be the final name, or whether it will be std.mem.dupe
noonien has quit [Quit: Connection closed for inactivity]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]