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
<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
<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..
<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>
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
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'
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 ?