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/
ntgg has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 248 seconds]
st4ll1 has quit [Ping timeout: 245 seconds]
marijnfs has quit [Quit: WeeChat 2.4]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 272 seconds]
man213 has quit [Quit: Going offline, see ya! (www.adiirc.com)]
ntgg has quit [Ping timeout: 245 seconds]
marijnfs__ has joined #zig
<daurnimator> torque: last thing I remember with non-8 bit chars was the Texas instruments dsps popular from 2005-2009
<daurnimator> I hear some qualcom dsps may still have a weird char size today; but all the info seems to be under NDA
marijnfs_ has quit [Ping timeout: 246 seconds]
<fengb> How do I assert not undefined?
kristoff_it has joined #zig
batok has quit [Remote host closed the connection]
kristoff_it has quit [Ping timeout: 245 seconds]
<daurnimator> you don't
<scientes> yeah undefined will cause compiler errors sometimes unnecessarily too
<scientes> its a hard problem
<scientes> undefined should generally just propagate, the exception is when you try to branch on undef
<fengb> It’s for debugging only
<scientes> undefined is also a compiler optimization
<fengb> I’d like to check for 0xaa in safe builds and not check at all in release-fast
<scientes> that's how it started
<scientes> fengb, you can't check undef
<scientes> fengb, well you could do exactly that....
<scientes> zig is already pushing the limit by erroring out on undef
<scientes> which may limit valid optimizations
<scientes> maybe there should be a way of doing a silent undef
<scientes> that can't result in a compiler error
<scientes> but that is quite a bit of work
<daurnimator> fengb: undefined is only 0xaa sometimes
<fengb> Oh? I’ll create my own sentinel then. I thought it was standard
<daurnimator> fengb: e.g. for static data I think it's null bytes. and I've been in callback situation where it ends up as junk
<daurnimator> fengb: undefined is.... undefined => it can be *any* value
<scientes> yeah generally you should only check for 0xaa in the debugger
<scientes> and valgrind is smarter with zig than C
<scientes> IIRC
<daurnimator> scientes: yep. thanks to the valgrind instruction we emit :)
<fengb> I was thinking of explicitly setting undefined as a special value since null was already used. But if it’s not consistent, I’ll find a separate magic number
<scientes> is there any reason to not have maxInt and minInt return the corresponding int type?
<scientes> instead of comptime_int
<daurnimator> scientes: that's IntFittingRange
<scientes> you can always cast it back to comptime_int
<daurnimator> oh wait I misunderstood the question
<scientes> u16(std.math.maxInt(u16))
<scientes> this is annoying
<daurnimator> scientes: I think that change would make sense
<daurnimator> scientes: send a PR?
<scientes> yeah i will
<scientes> maxInt(i32)
<scientes> oh that is fine, nvm
<scientes> hmm, the existing tests will only pass with that change if we implement > and < between signed and unsigned
ntgg has joined #zig
ntgg has quit [Ping timeout: 268 seconds]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 248 seconds]
laaron has quit [Remote host closed the connection]
laaron has joined #zig
kristoff_it has joined #zig
NI33_ has quit [Ping timeout: 248 seconds]
kristoff_it has quit [Ping timeout: 268 seconds]
<andrewrk> comptime_int is intentional for std.math.maxInt and std.math.minInt
laaron has quit [Remote host closed the connection]
<andrewrk> why do you need to cast it
laaron has joined #zig
<andrewrk> AlexMax, as a first pass, a correct implementation with a quality test suite wolud be preferred. as long as the API is reasonable then a faster implementation will come around eventually
_whitelogger has joined #zig
_whitelogger has joined #zig
NI33_ has joined #zig
_whitelogger has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 246 seconds]
zacharycarter has joined #zig
<zacharycarter> does anyone have any idea when - https://github.com/ziglang/zig/issues/1481 - might be resolved, or does anyone have an idea of how much work it is to actually resolve some of these ABI compatibility issues?
<daurnimator> zacharycarter: > leave a comment detailing your specific needs and I'll see if I can code those up for you to unblock you, so you don't have to wait for this issue to be 100% solved.
<daurnimator> zacharycarter: at the moment issue 2377 (coroutines) is the top priority. essentially everything is on hold until that is complete.
<zacharycarter> daurnimator: ah okay gotcha, thank you! I'll do what you suggested and compile a list of blockers and add it to the issue
curtisf has joined #zig
<daurnimator> andrewrk: https://clbin.com/1vsPp <-- love it
<daurnimator> andrewrk: `const p = async first();` -- shouldn't this be `var`? isn't `p` essentially getting modifed?
<andrewrk> daurnimator, the const is actually ok in the variable initialization (that's the same as `const x = initStruct();`, but then yeah `resume p` should be a compile error
<andrewrk> hmm that frame copy is inadvisable. that should probably also be a compile error
<andrewrk> async function frames are immovable
<daurnimator> andrewrk: why?
<daurnimator> zig doesn't really have the concept of immovable types
<daurnimator> andrewrk: but also, being able to copy a frame like that is *awesome*
<andrewrk> multiple reasons. (1) when it is called with `async` and there is a return value, the result is stored in the frame, with a pointer to the result also stored in the frame (2) if the function takes the address of a local variable (3) the awaiter field needs to be atomic, it is touched by multiple threads
<daurnimator> andrewrk: you could use it to e.g. serialise pending operations and give them out as signed tokens to get a stateless server
<andrewrk> I don't fully understand your example, but can't you do that with just normal async/await semantics?
<daurnimator> andrewrk: i'll have to think a little more about that
<andrewrk> zig's async functions are designed to be like normal functions: there is one caller, one callee
<daurnimator> at the moment they feel 90% of the way to a call/cc primitive
<andrewrk> copying a function call mid-call is not something that makes sense semantically
<daurnimator> andrewrk: btw, https://clbin.com/p4Js0 still doesn't work
<andrewrk> ok let me take a look since I'm between commits
<daurnimator> andrewrk: trying to call a non-async function with `async` resulted in a compiler assertion. relevant stack frame: #7 0x0000555555ab0f3f in resolve_llvm_types (g=0x555556517c20, type=0x555558a0f210, wanted_resolve_status=ResolveStatusLLVMFwdDecl) at /home/daurnimator/src/zig/src/analyze.cpp:7608
<andrewrk> daurnimator, that's in the BRANCH_TODO list
<daurnimator> ah k
<daurnimator> Other misc thing... why are stack traces so slow right now? I just straced during an assertion and saw: https://bpaste.net/show/J9wD the mmap suggests some growing buffer..
<andrewrk> it's the new code that lemonboy added: https://github.com/ziglang/zig/issues/2458
<andrewrk> it's doing some O(N) thing instead of binary search or something like that
<andrewrk> should be a fun one to fix I think
<andrewrk> I mean legitimately, not sarcastically
<daurnimator> I've met the horrors of dwarf before. I might leave that for someone else :p
dimenus has quit [Read error: Connection reset by peer]
laaron has quit [Remote host closed the connection]
kristoff_it has joined #zig
laaron has joined #zig
terinjokes has quit [Quit: ZNC - http://znc.in]
terinjokes has joined #zig
kristoff_it has quit [Ping timeout: 246 seconds]
mikdusan1 has joined #zig
mikdusan has quit [Ping timeout: 248 seconds]
<andrewrk> daurnimator, here you go, try your resume thing now: e444e737b786afd0c5aba2ea04c901f89c57813e
<daurnimator> andrewrk: does this mean we can't have two versions of a function?
<andrewrk> are you asking about copying a frame again?
<daurnimator> no. 'compile error for casting a function to a non-async function pointer, but then later it gets inferred to be an async function'
<andrewrk> oh I see. hmm maybe that's a good way to resolve that issue
<andrewrk> I like that
<andrewrk> wait
<andrewrk> no, that won't work. if a function calls an async function then it must be async
<andrewrk> that compile error describes a situation where a non-async function pointer, points to an async function. that is invalid
<daurnimator> what if a function calls a callback passed as a parameter?
<daurnimator> `fn foo(bar: fn (void) void) { bar(); }` -> now call foo once with an async function; and then with a non-async function
<andrewrk> show me the test case and I'll tell you expected behavior
jjido has joined #zig
<daurnimator> andrewrk: earlier, what did you mean by "try your resume thing"
<andrewrk> <daurnimator> andrewrk: btw, https://clbin.com/p4Js0 still doesn't work
<daurnimator> andrewrk: got 'awaiting function resumed'
SimonNa has quit [Remote host closed the connection]
<andrewrk> brilliant. safety crash instead of undefined behavior
<andrewrk> daurnimator, in your example, `first` is an async function which is awaiting the function call to `other`. the only valid way for first to get resumed is when `other` returns
<andrewrk> that's why in the test case, when it passes, the `resume` corresponds to the actual `suspend` - it's resuming `other`'s frame, not `first`'s
<andrewrk> the way to think about them is that they are functions that can suspend themselves. when a function suspends itself, it better have a plan for how it's going to get resumed. in the example of this test case, the plan is that it puts its frame into a global variable, and then doTheTest resumes it
<daurnimator> okay makes sense
<daurnimator> but it sort of sounds like having `async foo()` return something is a bit of a footgun then
<andrewrk> the frame has to go somewhere
<daurnimator> true
<andrewrk> you should look at the code at the bottom of https://github.com/ziglang/zig/issues/2377#issuecomment-514399473 again. this is what most code will look like
<andrewrk> it's just async/await
<andrewrk> point being that everything works with defer,errdefer,try, and all the rest of the language features
<andrewrk> resource management will be reasonable
<daurnimator> andrewrk: `frame2.* = async parseFile(allocator, "bar.txt");` even though we have result-location semantics... this ends up feeling like a copy
<daurnimator> I wonder if `async` should take a frame pointer.....
<andrewrk> @asyncCall takes []u8 or a frame pointer, as well as a result pointer
<daurnimator> I guess that gets into @asyncCall(parseFile, frame2, allocator, "bar.text")
<andrewrk> @asyncCall doesn't take an allocator
<andrewrk> oh, I see that's an arg, sorry
<andrewrk> the point of using result location is so that this works: var frame = async foo(); const result = await frame;
<daurnimator> but that doesn't work... unless you know foo() doesn't suspend in a subfunction?
<andrewrk> I think you're getting resume and await mixed up
<andrewrk> async is matched with await or cancel. suspend is matched with resume
<daurnimator> ah
<andrewrk> suspends cannot be canceled; they must be resumed
<daurnimator> except that you can only await on something suspended?
<daurnimator> be back later; gotta walk the dog. though I imagine you should go to bed :)
<andrewrk> this example is hitting: * compile error for casting a function to a non-async function pointer, but then later it gets inferred to be an async function
<andrewrk> your example would cause the _start function to be async, which is not allowed
<andrewrk> await is a suspend point, you can't await in a non-async function
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<daurnimator> back
<daurnimator> btw, reading through the traceback code. we open /proc/self/exe. Could we get the same info from looking at AT_PHDR?
curtisf has quit [Ping timeout: 260 seconds]
laaron has quit [Remote host closed the connection]
laaron has joined #zig
laaron has quit [Client Quit]
laaron has joined #zig
wootehfoot has joined #zig
kristoff_it has joined #zig
_whitelogger has joined #zig
laaron has joined #zig
jjido has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<scientes> daurnimator, yes
odc has quit [Ping timeout: 252 seconds]
tghume has quit [Ping timeout: 252 seconds]
strmpnk has quit [Ping timeout: 252 seconds]
tghume has joined #zig
strmpnk has joined #zig
odc has joined #zig
<mq32> hm
<mq32> maybe i should wait for the next release cycle until i start the game project…
<mq32> empty project fails to compile for i386-windows-msvc
<Sahnvour> mq32: see https://ziglang.org/#Wide-range-of-targets-supported, this is supposed to work but not tested regularly so you may encounter more difficulties than for x64
<mq32> ah, damn
<mq32> can't use x86_64 sadly
kristoff_it has quit [Ping timeout: 246 seconds]
<Sahnvour> what's your system ?
<mq32> arch linux x86_64
<mq32> but the library i want to use only exists for i386-windows-msvc
<Sahnvour> I doubt an empty program should fail to compile though, what's the error ? It can be worth reporting it
<mq32> made an issue already
<mq32> two compile errors
<mq32> one is a usize/u64 problem, the other one some assembler stuff
<Sahnvour> oh okay, the usize one is my fault actually, but as you noted it's easy to fix
<Sahnvour> don't know about there asm errors
<mq32> dunno if the usize thing is fixed like this
<mq32> but it *should*, as we can't read more than 4 GB on i386
<Sahnvour> `size_to_read` should initially be a `usize` I guess
<mq32> yeah, probably
laaron has quit [Remote host closed the connection]
kristoff_it has joined #zig
laaron has joined #zig
kristoff_it has quit [Ping timeout: 258 seconds]
Ichorio has joined #zig
laaron has quit [Remote host closed the connection]
laaron has joined #zig
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #zig
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 268 seconds]
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #zig
jjido has joined #zig
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
nairou has quit [Quit: Leaving]
laaron has joined #zig
batok has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 244 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
andersfr has joined #zig
laaron- has joined #zig
laaron has quit [Ping timeout: 260 seconds]
kristoff_it has joined #zig
andersfr has quit []
batok has quit [Remote host closed the connection]
<andrewrk> daurnimator, scientes: no. we open /proc/self/exe to get the DWARF info, which is not mapped into memory on program startup
laaron- has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #zig
batok has joined #zig
<batok> join ##C
wootehfoot has quit [Read error: Connection reset by peer]
<scientes> open != lstat
<scientes> my misunderstanding
<scientes> lstat of /proc/self/exe
<scientes> is indeed AT_PHDR
<andrewrk> what? AT_PHDR is in the aux vector that the kernel gives, showing where the program headers are mapped into memory. this has nothing to do with soft links
<nrdmn> is there any convenient syntax to add padding in a struct without having to declare an unused attribute?
<scientes> oh its a little differn't from /proc/self/exe AT_EXECFN
<scientes> as it can be a relative path
<scientes> and unlike argv[0] is not what is passed by the execve() caller
<andrewrk> nrdmn, you can give a field a default value of undefined
<Sahnvour> andrewrk: just rebased on master (and installed) and when compiling a snippet I wrote some time ago I get :
<Sahnvour> zig\lib\zig\std\special\start.zig:124:35: error: root source file has no member called 'main'
<Sahnvour> switch (@typeInfo(@typeOf(root.main).ReturnType)) {
<Sahnvour> something to do with zig-cache ?
<Sahnvour> no wait, i'm an idiot, there is no main, only a test, my bad
<Sahnvour> let's do a friendlier @compileError for this
<scientes> I thought it was fine
<scientes> but yeah, no objection
jjido has joined #zig
batok has quit [Remote host closed the connection]
diltsman has joined #zig
<diltsman> For @cImport, how do i get system files, like Windows.h? Also, how do you add search paths?
<diltsman> donpdonp: Thanks!
ltr- has joined #zig
<Sahnvour> daurnimator: pardon my notifications via github's review tool, I have no idea how it works
MH026 has joined #zig
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
batok has joined #zig
<emekankurumeh[m]> perhaps there should be an issue "purge" sometime to remove stale issues or issue that no longer apply
jjido has quit [Read error: Connection reset by peer]
laaron has joined #zig
<scientes> emekankurumeh[m], andrew does that
andersfr has joined #zig
andersfr has quit [Client Quit]
Ichorio has quit [Ping timeout: 264 seconds]
kristoff_it has quit [Ping timeout: 268 seconds]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
nairou_ has joined #zig
nairou_ is now known as nairou
<ltr-> there is somthing like condition_variable in the std?
MH026 has quit [Remote host closed the connection]
rjtobin has joined #zig
MH026 has joined #zig
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
Akuli has joined #zig
laaron has joined #zig
kristoff_it has joined #zig
zacharycarter has quit [Ping timeout: 248 seconds]
kristoff_it has quit [Ping timeout: 246 seconds]
<andrewrk> emekankurumeh[m], note that there are no issues with old milestones
<andrewrk> ltr-, not yet
<andrewrk> ltr-, if you're linking libc you can use posix apis
<ltr-> andrewrk: k thx, i have to implement a waiter that can be signaled from 2 different threads, any advice to implement something simple and not cpu intesive like spin locks?
<andrewrk> ltr-, my suggestion would be to either use the posix condition/signal APIs or work on adding these APIs to the zig std lib directly
rom1504 has quit [Remote host closed the connection]
<andrewrk> what are your target platforms?
<ltr-> ill use pthreads with a thin layer of abstraction for now
<ltr-> im doing a tiny rpc server
<ltr-> for a language server implementation
rom1504 has joined #zig
<ltr-> using 2 threads one for stdin and another for stdout
<ltr-> and the main thread takes care for query the DB and fire indexing threads
<ltr-> any advice will be much appreciated
<ltr-> so far i have the request response and request handlers. but the main thread suck up all the core, cos im using a naive waiter. basically a mutex and a flag.
<andrewrk> the async/await stuff I'm working on right now will make this much nicer
<andrewrk> you don't really need mutexes or condition variables with event-based
<ltr-> nice, coroutines will make this so easy.
<ltr-> what do you recommend?
<ltr-> i just want to know if there is an item in two different queues.
<andrewrk> maybe you can use pipes for now
<andrewrk> and poll()
<Sahnvour> andrewrk: are your mascot propositions based on puns, references or something ?
<fengb> Zigbee, Ziggurat, and Zero Wing
<Sahnvour> thanks
dimenus has joined #zig
<scientes> awesome exploit against zigbee and wifi https://www.youtube.com/watch?v=euMHlV6MNqs
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #zig
batok has quit [Remote host closed the connection]
<dimenus> scintes: i just merged your simd5 branch with master and it throws a zig compiler bug when assigning to vector component
<dimenus> the branch itself is fine though
<dimenus> *scientes
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 268 seconds]
<emekankurumeh[m]> if we have @asyncCall what about @call?
Akuli has quit [Quit: Leaving]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 272 seconds]
rom1504 has quit [Quit: WeeChat 1.6]
<andrewrk> emekankurumeh[m], for what purpose?
Ichorio has joined #zig
<emekankurumeh[m]> we have @asyncCall, @noInlineCall, @inlineCall, @newStackCall, but no basic @call builtin
<andrewrk> but each of those has a purpose. what would be the purpose of @call?
ltr- has quit [Quit: leaving]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 246 seconds]
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #zig
meowray has quit [Quit: ZNC 1.7.1 - https://znc.in]
return0e has quit [Ping timeout: 272 seconds]
return0e has joined #zig
\u has joined #zig
darithorn has joined #zig
dimenus has quit [Remote host closed the connection]
Ichorio has quit [Ping timeout: 264 seconds]
marijnfs has joined #zig
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #zig
kristoff_it has joined #zig
laaron has quit [Client Quit]
laaron has joined #zig