<daurnimator>
andrewrk: btw, we might want to rename "cancellation point". people coming from C/POSIX will get very confused....
<scientes>
daurnimator, did you figure out the arm64 ci?
<daurnimator>
scientes: what do you mean by "figure out"
<scientes>
oh there was a confusion that it wouldn't work
<daurnimator>
scientes: I ran into an issue where at least the docker driver is completely broken on arm64
<scientes>
just use shell mode
<scientes>
instead of docker
<scientes>
its faster anyways
<scientes>
zig doesn't need docker
<daurnimator>
shell mode leaves quite a lot of potential for mess left behind
<scientes>
it starts with a clean checkout every time
<fengb>
Reboot every night? :P
<scientes>
otherwise the "mkdir" would fail
<scientes>
as it lacks a -p
<daurnimator>
scientes: I meant files leaking elsewhere onto the system
<scientes>
yes, that is possible, but in the case of ccache that is desired
<daurnimator>
usually for CI systems you explicitly call out certain directories to be kept
<daurnimator>
fengb: reboot won't erase things :P
<daurnimator>
I wonder if we can use shell mode but do all the operations in a container manually
<scientes>
its not really necessary
<daurnimator>
docker run -it debian bash -s << EOF ............ script here ...............
<daurnimator>
or something like that
<scientes>
for systemd, yes you need it, but zig doesn't need some complicatedness
<fengb>
Toss /usr into a ramdisk. Problem solved!
<fengb>
Er, /var, /home, whatever
<scientes>
/usr/lib/gitlab-runner
<daurnimator>
scientes: assuming no bugs in zig.... or stupidness. but recall that we're running arbitrary code from people sending PRs: we don't want a bad PR messing up the system
<scientes>
> but recall that we're running arbitrary code from people sending PRs
<scientes>
ahhh good point
<scientes>
we could add a before script that just deletes everything in ~ (which is the only writable directory, aside from /tmp)
<scientes>
or even better
<scientes>
run a script that creates a new mount namespace, in which only the build directory is writable
<daurnimator>
yep... you could call that script.... docker :P
<scientes>
docker is overkill however
<scientes>
all the COW stuff
<daurnimator>
overkill is still a kill
<dimenus>
did andrewrk stream tonight?
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 244 seconds]
<daurnimator>
andrewrk: no
<daurnimator>
oops
<daurnimator>
dimenus: no
<dimenus>
hah
<nairou>
What is the process for building zig on Linux? My distro doesn't have a premade package, and I only see Windows/Mac instructions on the website.
<daurnimator>
andrewrk: in #1778 you have @handle() in your examples. what does that map to in the current design?
<andrewrk>
I've got await working in the rewrite-coroutines branch. most coroutine tests passing now. it felt great to delete all those `catch unreachable`, `async`, and `<allocator>`
<andrewrk>
daurnimator, @frame
<daurnimator>
andrewrk: so it would be e.g. `event_loop.queueFsWrite(@frame(), &msg);`? where .queueFsWrite would call it's first argument to resume the coroutine?
<andrewrk>
these semantics are slick. I think people are going to be happy with this
<daurnimator>
And that @frame() could be stored in some heap-allocated location?
<andrewrk>
daurnimator, `resume foo;` works with these types: `*@Frame(func)`, `anyframe->T`, or `anyframe`. all 3 of those are pointer types
<andrewrk>
I'll push a test case with a heap allocated frame so you can see
<nrdmn>
daurnimator: I uploaded a few demo apps for my PR :)
<daurnimator>
nrdmn: cool :)
<andrewrk>
daurnimator, ok actually I need to fix a result location issue to make that work: https://clbin.com/rbCkH
<daurnimator>
andrewrk: also I tried poking about on top of your branch but kept hitting assertions; obviously its not ready yet so I think I just need to keep waiting :P
<andrewrk>
yes, that or stick to minor deviations from the set of passing tests (behavior tests are all passing in the branch)
<daurnimator>
andrewrk: so in e.g. "calling an inferred async function", what *is* in the @frame?
laaron has quit [Remote host closed the connection]
<daurnimator>
and then if I apply https://clbin.com/Gvdbi ... then `a` is evidently in the @frame()
<andrewrk>
1. pointer to the function to call when resuming 2. pointer to the awaiter frame / cancel bit 3. pointer to the return value 4. return value 5. all the parameters 6. all the local variables
<andrewrk>
oh, oops. I didn't even wire up result location semantics for the assignment operator
fsateler has quit [Ping timeout: 244 seconds]
<daurnimator>
https://clbin.com/opH3c gives me "invalid resume of async function". expected? I was wondering if we had a call/cc style setup
<andrewrk>
yes you can't resume a function which has returned
laaron has joined #zig
<andrewrk>
each suspend should have exactly 1 resume corresponding to it
<daurnimator>
I thought all its state would be 'snapshot' into `extra_frame` so that it wouldn't know it hasn't returned
<andrewrk>
@frame() returns a `anyframe->T` which is a pointer type
ntgg has joined #zig
<andrewrk>
sorry, it returns *@Frame(other) as you have in your source, which are pointer types
<andrewrk>
other_frame == extra_frame in your example. they are both the address of `p` inside doTheTest
<daurnimator>
ah okay, so it's really just `p`
<daurnimator>
so instead of `resume other_frame.*` I could write `resume p`?
<andrewrk>
yes
<daurnimator>
test failure says otherwise :P
fsateler has joined #zig
<andrewrk>
yeah I wouldn't go about trying to fix the event loop code with this branch just yet :)
<daurnimator>
andrewrk: btw, try and use `expectEqual` instead of `expect`?
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ichorio has joined #zig
NI33_ has joined #zig
Ichorio has quit [Ping timeout: 264 seconds]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 244 seconds]
ntgg has quit [Ping timeout: 245 seconds]
<mq32>
hey
<mq32>
does zig currently has any user-defined types where the user is not able to add any methods?
<mq32>
@OpaqueType would be a candidate, but it's a rather special case
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
<samtebbs>
mq32: Could you elaborate on what you mean by "user-defined types"?
<mq32>
anything that is not a built-in type
<samtebbs>
I don't quite understand how a user (i.e. programmer) would define a type but not be able to add a func/method
<mq32>
struct, enum, union, ... are used-defined type
<mq32>
u32 would be built-in
<mq32>
but @OpaqueType is kinda user-defined (as in: the user has to give the type a name) but also not (as in: the user cannot decide anything about the types properties)
<samtebbs>
That makes sense
<samtebbs>
What's your use case?
<mq32>
"writing issues on github"
<mq32>
or better: answering to issues on github
<mq32>
looks like we only have "error" and @OpaqueType and both are special…
<samtebbs>
Oh I see :)
<samtebbs>
Yeah it doesn't look like it's possible with standard zig
<samtebbs>
It's an unusual feature
<mq32>
which one do you mean?
<mq32>
i don't want to add methods to each opaquetype and error :P
ntgg has joined #zig
<ntgg>
why is auto indent spaces sometimes when I have indentation as tabs?
<daurnimator>
ntgg: zig is always spaces.
<ntgg>
wrong channel
<ntgg>
my b
<mq32>
just indent with backspaces!
jjido has joined #zig
<daurnimator>
pffft. everyone knows to use non-breaking spaces. it makes no sense for indentation to get line-broken
<mq32>
true dat
kristoff_it has joined #zig
dimenus has joined #zig
dimenus has quit [Remote host closed the connection]
kristoff_it has quit [Ping timeout: 246 seconds]
<euantor>
Any idea why the following code would cause `error: container 'std.os' has no member called 'getrandom'`? Same goes for `os.open()`, `os.close()`, etc... https://www.irccloud.com/pastebin/Qq94IyZK/
<euantor>
Also fails on godbolt as well as locally with master
<euantor>
ok, works on zig trunk on godbolt but not 0.4.0
<daurnimator>
std.os was rearranged between 0.4.0 and now.
<euantor>
ah, that's probably the problem then. Thanks!
<daurnimator>
euantor: btw, you might prefer std.crypto.randomBytes
<daurnimator>
oh wait now. there's even std.rand now.
<euantor>
I'm looking to see if I can fix an old issue I made to dip my toes into the stdlib
batok has joined #zig
batok has quit []
<samtebbs>
mq32: I mean the feature of having a user-defined type that you can't define functions for. It's quite unusual so there probably isn't a clean way to do it.
<ntgg>
it only happens on a struct with more than one field
<fengb>
Go allows it for aliases. It’s where I learned that it’s possible
<mq32>
samtebbs, i think we're talking about different things, but very similar
<ntgg>
My issue seems to be caused by returning an error, even if it doesn't go down that path
<samtebbs>
ntgg: You could try to minimise it then run it through gdb
Tetralux_ has joined #zig
Tetralux_ is now known as Tetralux
batok has joined #zig
mschwaig has joined #zig
laaron has quit [Remote host closed the connection]
laaron has joined #zig
<ntgg>
samtebbs: the error is seemingly when compiling the tests, so I'm not quite sure how to run it through gdb
laaron has quit [Remote host closed the connection]
<samtebbs>
ntgg: What command are you using to compile?
<samtebbs>
If you're using `zig build`, then add --verbose to see what it's running, then run `gdb --args <the command that segfaults>`
<samtebbs>
Otherwise run `gdb --args <your zig command here>`
laaron has joined #zig
mschwaig has quit [Remote host closed the connection]
<ntgg>
samtebbs: it says the segfault is in llvm::BasicBlock::getContext()
<samtebbs>
ntgg: Ok, so Zig is passing some as null that shouldn't be. Do you see what line it's failing on?
<ntgg>
I don't use gdb that much, so I'm not sure if I'm missing something, but I don't see any line numbers anywhere
<ntgg>
actually it says no line number information
<samtebbs>
Ah that's probably because it's LLVM and gdb isn't reading the debug symbols for it. You could probably read them in but it may not give us what we want.
<samtebbs>
You could create an issue with the information that you have (if there isn't one open for the problem already).
<firefox317>
Hmm reading the comments there I think what nrdmn says is correct, at least one byte, but it can be bigger
<fengb>
I'm actually curious now. We do store abi_size separately but I ahven't tracked down where it comes from
<mikdusan>
LLVM api?
firefox317 has quit [Remote host closed the connection]
<torque>
is there even real life actual hardware that anyone uses where CHAR_BIT != 8
<nrdmn>
torque: PDP 10, some PIC microcontrollers...
<nrdmn>
actually I do need a bool that is exactly 1 byte large, not more, not less. I could use u8, but I like the convenience of being able to write if (condition) instead of if (condition != 0)
<fengb>
A lot of pre-C99 used int/word as bool
<fengb>
Processor word, not wintel “word”
<nrdmn>
I'm not sure if intel is to blame for C ints on recent x86 being larger than what they call a "word"
<nrdmn>
and by 'recent' I mean >= i386
<fengb>
It’s in their documentation that word = 16 bits. It’s also hard coded in Windows
<fengb>
Defined in 8086 apparently
st4ll1 has joined #zig
ltr- has joined #zig
ntgg has quit [Ping timeout: 244 seconds]
darithorn has joined #zig
jjido has joined #zig
<nrdmn>
I'd like to propose the types boolN, where N is any natural number. their size is N bits. bool can be an alias for bool1. boolN types can be used in conditions without additional comparison operators being necessary. They can be implicitly cast into into other boolN types because their only valid values are 0 and 1.
<nrdmn>
(don't take this too seriously)
<dimenus>
i can't get zig on mingw to build again
<dimenus>
and i can't figure out what's different from what I did the other day
<dimenus>
getting linker errors to z3_*
<dimenus>
z3 is installed
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<halosghost>
Tetralux: partly because I enjoy bit-packing and you could implement arbitrarily-sized, fixed-width integers on top of 1-bit bytes
<halosghost>
doesn't matter as much in zig because I already have those
<halosghost>
but, I could implement 2's complement arithmetic on top of a bit array and then, whatever size of array you have is the size of the integer :D
<dimenus>
emekankurumeh[m]: what did you change?
<dimenus>
i got it to link statically, but only with lld
<andrewrk>
mq32, yes, defer and errdefer will work identically whether a function is async or not. the only difference is that async functions have the possibility of running the errdefers when a function returns if the caller "cancels"
<andrewrk>
this is already idiomatic zig, however, which is that when a function returns, the errdefers in scope should be correct, so that e.g. a `try` could be used directly before the `return`
<mq32>
hm
<mq32>
so if i cancel a function that uses defer, i got a potential memory leak?
<andrewrk>
that's not quite right. I can see that I'm going to need to use more intuitive names for these semantics
<andrewrk>
a function call is the same whether or not it is async. just like the operating system can suspend and resume your normal blocking functions, in zig, async functions can be suspended and resumed, but without the kernel intervening
<fengb>
Would a cancel have its own error code?
<fengb>
I should save my questions until I have a chance to play with it :P
<andrewrk>
no - cancel is the same as await, except: (1) it sets a cancel flag that the caller may choose to read at any time, and (2) if the async function gets to a `return` and the cancel flag is set, then it runs not just the defers but also the errdefers
<andrewrk>
if you want to make there be a cancelling error code, you would do something like this: if (@isCancelled()) { return error.PardonMeButThereHasBeenAnInterruption; }
<andrewrk>
without anything like that, functions proceed from start to end just like normal. no hidden control flow. again the only difference is that `return` might end up running the errdefers even if there wasn't an error
<andrewrk>
`cancel` from the caller's perspective, in english, means, "I am choosing to not await this. If it was going to do any side effects or resources, I don't want them and I shan't be keeping track of them."
<andrewrk>
maybe cancel can be renamed to `noawait`
<dimenus>
andrewrk: do we still call ld.link with mingw64 builds
omglasers2 has joined #zig
<emekankurumeh[m]>
yes but with the -lldmingw flag first
<andrewrk>
dimenus, yes, with -lldmingw
<mq32>
andrewrk: i was asking as the engine i want to work with utilized endless coroutines in the original version to implement entity behaviour
<mq32>
and i am tempted to recreate that behaviour with zig, but with the option to have safe memory allocation in those coroutines (by deferring the memory release)
<dimenus>
andrewrk: hmm, clang calls ld.lld - thinking through using dwarf on mingw
man213 has joined #zig
<fengb>
In single threaded, does that mean cancel would still await?
<emekankurumeh[m]>
would it be undefined behavior for a coroutine to free it's own memory in it's defer
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
marijnfs has joined #zig
aeqwa has quit [Ping timeout: 260 seconds]
<hryx>
nrdmn: so coooool
darithorn has quit [Quit: Leaving]
drazan has joined #zig
st4ll1 has joined #zig
ntgg has quit [Ping timeout: 272 seconds]
omglasers2 has quit [Read error: Connection reset by peer]
kristoff_it has joined #zig
<AlexMax>
Got a question. The DEFLATE ticket noted that the implementation of zig-deflate library wasn't built for speed. What does that mean? There's lots of deflate implementations out there of varying complexity, and it seems wise to have implementation preferences up front if they exist.
<AlexMax>
I note that the source implementation for zig-deflate appears to be puff.c, which seems to be aimed at correctness and not speed. So I suppose pretty much any other implementation other than that would be preferred? (zlib proper?, zlib-ng?, possibly Go's implementation?)