dimenus has quit [Remote host closed the connection]
ltriant has quit [Ping timeout: 276 seconds]
wootehfoot has quit [Read error: Connection reset by peer]
<bhansconnect>
Is the current for of async await in zig limited to one core/system thread?
clktmr has quit [Ping timeout: 240 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
lunamn_ has joined #zig
lunamn has quit [Ping timeout: 268 seconds]
leeward has joined #zig
dantix has quit [Remote host closed the connection]
dantix has joined #zig
kllr_sbstn has quit [Quit: leaving]
lunamn_ has quit [Quit: leaving]
waleee-cl has quit [Quit: Connection closed for inactivity]
<pixelherodev>
Thought experiment: what happens if you have two `defer return VALUE;` statements? :P
ltriant has joined #zig
<leeward>
Can you return in a defer?
<leeward>
It's supposed to happen when you leave the stack frame, right?
doublex_ has quit [Ping timeout: 240 seconds]
<pixelherodev>
Exactly
ltriant has quit [Ping timeout: 240 seconds]
dimenus|work has quit [Read error: Connection reset by peer]
<bhansconnect>
error: cannot return from defer expression
<pixelherodev>
Makes sense :)
<bhansconnect>
that is what the compiler will tell you
doublex has joined #zig
crimson_penguin has quit [Ping timeout: 264 seconds]
crimson_penguin has joined #zig
<leeward>
Yeah, that's what I figured.
<andrewrk>
bhansconnect, no, the default is to use a thread pool with number of threads equal to cpu core count
<andrewrk>
zig's async/await language features are thread safe
muffindrake has quit [Ping timeout: 264 seconds]
muffindrake has joined #zig
ltriant has joined #zig
mahmudov has joined #zig
achaninja has joined #zig
ltriant has quit [Ping timeout: 240 seconds]
chemist69 has quit [Ping timeout: 246 seconds]
chemist69 has joined #zig
ltriant has joined #zig
kenaryn has joined #zig
<kenaryn>
Hi, does anybody know how to deal with user input?
<wilsonk>
kenaryn: I think there is a guess_number example in test/standalone/guess_number that should serve as an example
gsomix has joined #zig
<bhansconnect>
andrewrk, So for the fun of it, I converted my go multi goroutine factorial program to zig. In zig it will end up only using pinning to only one cpu for most of the computation and not use many of the threads. Not sure why.
<bhansconnect>
It should asynchronously multiply each chuck of the factorial, so I am not sure why it would be only using 1 thread for most of the computation.
<gsomix>
hey, everyone. I'm novice in zig, could you please review a very small program? thanks!
<achaninja>
gsomix i think you should abort or return an error instead of issue a warning on failure
<achaninja>
generally you want a non zero exit code on failure
ntgg has quit [Ping timeout: 268 seconds]
<gsomix>
achaninja thanks!
gsomix has left #zig [#zig]
gsomix has joined #zig
<gsomix>
I've just installed hexchat. haven't been in IRC in ages :)
<achaninja>
:)
ltriant has joined #zig
<bhansconnect>
andrewrk, I actually just realized the issue. Zig does not consider primitives like u64 as thread safe even if they are constants. Using a chan of u64 to send the parameters causes everything to run in parallel.
<kenaryn>
Thank you wilsonk.
ltriant has quit [Ping timeout: 240 seconds]
<wilsonk>
no problems kenaryn :)
<kenaryn>
Perhaps do you know a way to write into an external file instead of standard ouput? I do not see how to proceed, neither in the official documentation, nor the 'test' ghitub repository.
<kenaryn>
Many thanks! I just finished reading the master documentation a few hours ago, but didn't know about standard library's one, you are very kind.
<achaninja>
no problem , i just found it too
<achaninja>
it was linked from the page, but I missed it too
<kenaryn>
ahah yeah... silly me :)
dantix has quit [Quit: Quit]
ltriant has joined #zig
<andrewrk>
bhansconnect, ah, interesting, nice to see people playing with evented I/O
<andrewrk>
it's very new in the std lib, I'm sure there are issues
dantix has joined #zig
ltriant has quit [Ping timeout: 276 seconds]
dantix has quit [Quit: leaving]
<achaninja>
im curious about using it to avoid needing 'self pipe' trick in my process supervisor
<achaninja>
basically only react to signals in an event loop somehow
<achaninja>
and block signals while doing any calculation
<achaninja>
pretty interested in zero allocations regardless, zig is looking fun
mahmudov has quit [Remote host closed the connection]
<achaninja>
does zig anticipate many big upcoming language changes?
<andrewrk>
achaninja, have you seen the 0.5.0 release notes?
<andrewrk>
I recommend at least reading the table of contents and the roadmap section
<andrewrk>
btw bhansconnect just so you know - the std lib is not fully hooked up with evented I/O. as a proof-of-concept, reading is integrated, but writing is not yet. and for example these are also not integrated yet: sleeping/timing, child processes
<andrewrk>
by "not integrated" I mean that even when you select evented I/O, writing currently still blocks
<andrewrk>
oh, also file system stuff is not integrated yet
bhansconnect has quit [Ping timeout: 260 seconds]
<pixelherodev>
Out of curiousity, what's needed to implement a new backend to the event loop?
<dantix>
There is a thin wrapper around gmp for go. I guess using it will be more apples to apples comparison performance wise.
<soveran>
hi there, I'm just starting with zig and I'd like to know what's the fastest way to print to stdout lines read from stdin
<soveran>
(I tried std.io.readLineSlice(...), but I'd like to know if there's a faster approach)
<pixelherodev>
In theory you could use raw `std.os.read`/`std.os.write`
<pixelherodev>
That's what `std.fs.File` methods do under the hood
<pixelherodev>
So e.g. `std.os.read(std.os.STDIN_FILENO);` IIRC
<pixelherodev>
Not sure what other arguments you'd need
<pixelherodev>
A word-matching search for eql shows the source
<pixelherodev>
I don't think it'll make a performance difference though
<pixelherodev>
Again, always rely on a profiler to tell you what's really slowing your programs down, don't try guessing
<andrewrk>
soveran, have a look at the readUntilDelimiter functions in std/io/in_stream.zig
<andrewrk>
pixelherodev, yes callgrind works with zig. zig actually has valgrind integration, emitting valgrind-specific annotations for undefined memory
<soveran>
interesting
_whitelogger has joined #zig
<soveran>
yea, readLineSlice was the culprit. Thanks a lot :-)
<pixelherodev>
Suggestion: try using readLineSliceFrom with a constant stdin?