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/
<fengb> I just read that :P
ifreund has quit [Ping timeout: 258 seconds]
<wilsonk> jwmerrill: nice work on that Lox interpreter. Seems to work fine with Brave browser (based on Chrome)...just so you know
rjtobin has quit [Ping timeout: 246 seconds]
<oats> works nicely in qutebrowser too
aerona has joined #zig
BlondJesus has joined #zig
slurpie has quit [Ping timeout: 256 seconds]
dddddd has quit [Ping timeout: 256 seconds]
dnmllr has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
nephele has quit [Ping timeout: 260 seconds]
nephele has joined #zig
return0e has quit [Remote host closed the connection]
return0e has joined #zig
return0e has quit [Client Quit]
marijnfs has joined #zig
marijnfs1 has quit [Ping timeout: 256 seconds]
BlondJesus has quit [Ping timeout: 260 seconds]
curtisf has joined #zig
<curtisf> Did something change about how type-producing-functions get their identities? I'm getting strange looking errors `error: expected type 'grammar.Leaf("Iden")', found 'grammar.Leaf("Iden")'` https://gist.github.com/CurtisFenner/728854bd56f1a0ccaaade36c8cb37ca5
waleee-cl has quit [Quit: Connection closed for inactivity]
slurpie has joined #zig
<andrewrk> I'm looking forward to setting up compilation speed benchmarks and regression testing for self-hosted
<andrewrk> it's coming up very soon on my task list https://github.com/ziglang/zig/projects/2
curtisf has quit [Remote host closed the connection]
<oats> andrewrk: I have not paid attention to self-hosted progress, how far along is it?
<andrewrk> it's in the very early stages as far as language support, but I'm getting all the difficult design problem sorted out at the very beginning
<andrewrk> the only passing tests are here: https://github.com/ziglang/zig/blob/master/test/stage2/zir.zig
<andrewrk> but I have nearing completion implementation of incremental compilation
return0e has joined #zig
return0e has quit [Read error: Connection reset by peer]
daex has joined #zig
daex has quit [Quit: /me 's znc kicks the bucket]
slurpie has quit [Remote host closed the connection]
slurpie has joined #zig
daex has joined #zig
<foobles> andrewrk when using ir_create_basic_block_gen, is there any need to append them to the irb basic block list?
<foobles> i see there is ir_set_cursor_at_end_and_append_block, but that's only for IrBasicBlockSrc
<foobles> not gen
daex has quit [Ping timeout: 240 seconds]
daex has joined #zig
<foobles> oh: do I just call ir_finish_bb?
aerona has quit [Quit: Leaving]
daex has quit [Ping timeout: 258 seconds]
<foobles> huh, now I am getting unreachable code errors
<foobles> @andew
<foobles> andrewrk any advice?
<andrewrk> foobles, by convention the "create" ones don't append but the "build" ones do
<foobles> ohhhh thank you
<foobles> i didnt see that
<foobles> will that also fix the false-positive for unreachable code?
<foobles> wait, there is no ir_build_bb
<foobles> or basic_block
<andrewrk> hm doesn't the "if" analysis have to output such instructions?
<foobles> the only function that exists for making them requires an existing IrBasicBlockSrc
<foobles> oh, wait
<foobles> the build function does NOT append anthing
<foobles> it just calls ir_create_basic_block_gen, and then sets the IrBasicBlockSrc's child to be the new one
<foobles> so really, calling ir_create_basic_block_gen would be the best choice i think
<andrewrk> you might need to add a little bit of glue code to hook this up
frett27_ has joined #zig
<foobles> alright, ill see what the "if" analysis does
<foobles> thanks :)
Patrice_ has quit [Ping timeout: 256 seconds]
<foobles> alright, im going to go to bed now, thanks so much for the help
<foobles> this does feel way cleaner than generating llvm ir directly, despite all this :p
Patrice_ has joined #zig
foobles has quit [Ping timeout: 245 seconds]
frett27_ has quit [Ping timeout: 246 seconds]
Patrice_ has quit [Ping timeout: 258 seconds]
daex_ has joined #zig
cole-h has quit [Quit: Goodbye]
daex_ has quit [Ping timeout: 240 seconds]
daex has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
drp has joined #zig
_ray has quit [Quit: Connection closed for inactivity]
daex_ has joined #zig
daex has quit [Ping timeout: 272 seconds]
daex has joined #zig
daex_ has quit [Ping timeout: 260 seconds]
pystub has joined #zig
metaleap has joined #zig
dddddd has joined #zig
waleee-cl has joined #zig
dermetfan has joined #zig
pystub has quit [Ping timeout: 258 seconds]
wootehfoot has joined #zig
metaleap has quit [Quit: Leaving]
ikskuh has quit [Ping timeout: 272 seconds]
ifreund has joined #zig
metaleap has joined #zig
gazler_ has joined #zig
gazler has quit [Ping timeout: 265 seconds]
squeek502_ has joined #zig
xentec_ has joined #zig
benaiah` has joined #zig
commande1 has joined #zig
lohengrin_ has joined #zig
squeek502 has quit [*.net *.split]
xentec has quit [*.net *.split]
commander has quit [*.net *.split]
Lense has quit [*.net *.split]
andrewrk has quit [*.net *.split]
benaiah has quit [*.net *.split]
lohengrin has quit [*.net *.split]
benaiah` is now known as benaiah
lohengrin_ is now known as lohengrin
mq32 has joined #zig
mq32 is now known as ikskuh
FireFox317 has joined #zig
ur5us has joined #zig
rzezeski has quit [Quit: Connection closed for inactivity]
FireFox317 has quit [Remote host closed the connection]
<ifreund> so, i have a feature that is enabled by a build option which requires adding extra members to some structs when the option is enabled
<ifreund> my current pattern is `my_field: if (build_options.thing) MyType else void,`
<ifreund> am I correct in assuming that having a void member will have no effect if the option is false?
<ifreund> if so, anyone know of a better way to do this? I like the current solution but want to make sure it's not bloating my builds if the option is disabled
<daurnimator> ifreund: correct. a void field will take no room
<ifreund> one thing I haven't found a clean way to remove based on a build option is a variant of a tagged union
<ifreund> voiding the type is fine in theory, but would then require adding a check in every switch statement to do nothing if the build option is disabled
<ifreund> i'm using this tagged union to implement an interface of sorts, so I've swapped out the type with a dummy implementation with 0 size and every function simply containing an unreachable for now
<ifreund> i feel like there might be a better way though
<daurnimator> yeah I've hit that same issue before
<daurnimator> IMO @reify despite the drawbacks is the most sensible solution
<daurnimator> I've still got a tab open reminding me to finish https://github.com/ziglang/zig/pull/4586#issuecomment-593040078
slowtyper has quit [Quit: WeeChat 2.8]
<ikskuh> i really wonder why the maintainer of the AUR package "libc++" thought it was a good idea to run all tests on install :D
slowtyper has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
<daurnimator> ikskuh: build without running check?
<ikskuh> well
<ikskuh> yay -S libc++
<ikskuh> will build all tests
<ikskuh> :D
<ikskuh> by-default
cren has joined #zig
<cren> I'm learning Zig. How do I ask for a slice as the argument to a function (what's the syntax)?
<ikskuh> "[]T" for a slice to mutable data, "[]const T" for a slice to immutable data
<ikskuh> function taking a slice:
<ikskuh> fn foo(slice: []const u8) void { }
<cren> If the data is not going to be modified by the function, does it matter whether I use `const` or not (better performance?).
<ikskuh> it does matter. not for performance reasons, but for documentation and usability
<cren> good answer
<cren> I will use `const`
<ikskuh> you cannot pass const data to a non-const slice
<ikskuh> and it's always preferrable to have data const
<cren> I had specified the array as `const` so I guess I would be using a `const` slice anyway
<ikskuh> you wouldn't be able to use a mut slice then
linuxgemini has quit [Quit: ave on thelounge.lasagna.dev]
linuxgemini has joined #zig
<cren> When I use std.rand.Random, do I need to initialise it? I've seen it done in places but the example std/rand/ziggurat.zig doesn't seem to do it anywhere
<ikskuh> std.rand.Random is an interface
<ikskuh> if you want to get an instance to it, use a random generator engine
<ikskuh> var rng = std.rand.DefaultPrng.init(seed);
<ikskuh> rng.random.boolen(); // returns random boolean
<cren> ah I see
<cren> are all these random number generators going to always be available? or are they just being tried out because the language is new?
simontime has joined #zig
<ikskuh> zig std will be reviewed and reshaped before 1.0
<ikskuh> nothing in std is guaranteed to be kept
<ikskuh> but the code will probably still be available in separate packages
<cren> ok
moo has joined #zig
wootehfoot has quit [Ping timeout: 272 seconds]
dermetfan has quit [Ping timeout: 260 seconds]
slurpie has quit [Ping timeout: 264 seconds]
<ifreund> trying to update the zig packaage for void but getting an error building stage2 https://paste.rs/qHl
<ifreund> anyone seen this before? any ideas?
<waleee-cl> do /etc/conf contain it perhaps?
<ifreund> nope
marler8997 has quit [Read error: Connection reset by peer]
<ifreund> nice, removing `-DZIG_PREFER_CLANG_CPP_DYLIB=ON` fixed it
<ifreund> guess i didn't need that after ally
<ifreund> s/y//
<Dominic[m]> How can I pass the equivalent of `-l` to zig (cc)
<Dominic[m]> Nvm, I hadn't done something I thought I had :)
<Dominic[m]> I'm failing to get sys/types.h to #include from a `.h` file in my system. I notice that should be part of e.g. musl. Do I need to do something to get zig to provide that file? I'm not expecting to need to install glibc-devel on my machine to get the file to exist.
<ikskuh> i think you have to use "-target native-native-gnu"
dermetfan has joined #zig
<Dominic[m]> ikskuh: Trying `-target x86_64-linux-gnu` seems to be tripping up on needing stddef.h. I can see zig has that under `musl` and also `any-linux-any`, but I don't know how to "trigger" those
<ikskuh> is your source publicly available?
<ikskuh> i#d take a look
<Dominic[m]> Actually, it only got that far because I installed `glibc-devel`.
<drp> don't you have to use the -lc flag to bring in the libc?
<Dominic[m]> https://github.com/rxi/microui/tree/master/demo I'm running `zig cc -I../src -lc -lSDL2 -target x86_64-linux main.c -o demo` in an attempt to use zig to build the demo.
<Dominic[m]> Adding `-lc` was one of my attempts, same error with/without.
<ikskuh> are you on windows?
<Dominic[m]> No, linux
<ikskuh> which version of zig?
<ikskuh> mine "just works"
<Dominic[m]> Oh. 0.5
<ikskuh> maybe use 0.6 ;)
<Dominic[m]> I guess there was improvements in 0.6 here
<ikskuh> 0.5 doesn't really support "zig cc"
<ikskuh> it's a whole new feature
<ikskuh> "zig cc" in 0.5 is something completly different than in 0.6
<Dominic[m]> Oops, my mistake.
<Dominic[m]> I need to see if I can bump void linux's zig release really.
<fengb> You can try the downloads page. It’s a static build so should just work
<Dominic[m]> Something seems to be happening... :D
<Dominic[m]> ikskuh: did you manage a full build? Mine can't seem to find mu_pop_id which is defined in ../src/microui.x
<Dominic[m]> * ikskuh: did you manage a full build? Mine can't seem to find mu_pop_id which is defined in ../src/microui.h
<cren> I'm on Void Linux now and am happier now that I am using a 0.6.0 tarball instead of the package
<ikskuh> i have an a.out that crashes with the UBsan :D
<Dominic[m]> ikskuh: what was the exact build you used?
<ikskuh> zig cc main.c renderer.c ../src/microui.c -I ../src/ -Wall -std=c11 -pedantic `sdl2-config --libs` -lGL -lm -O3 -g -O2
ifreund has quit [Quit: WeeChat 2.8]
<ikskuh> the cli from build.sh
<Dominic[m]> Oh, missed the `../src/microui.c`. That would be helpful wouldn't it :)
<Dominic[m]> Thanks, that got it!
dddddd has quit [Ping timeout: 256 seconds]
<Dominic[m]> (As an aside, I did not expect it to open a window with windows inside... trippy. I expected native windows)
<Dominic[m]> Exploring options for building apps for the pinephone. I saw https://scattered-thoughts.net/writing/pinephone-first-steps/ and thought to try microui myself :)
<fengb> Oh you’re on a pine phone? How is it?
nycex- has joined #zig
nycex has quit [Ping timeout: 240 seconds]
ifreund has joined #zig
plumm has quit [Ping timeout: 260 seconds]
samtebbs has joined #zig
<samtebbs> Hi everyone, I saw that the extern keyword was replaced recently, does anyone know what I'd replace it with if when using externally declared functions?
<samtebbs> I don't care about the calling convention
<fengb> extern is still used for forward declarations
<fengb> I think there’s an issue to discuss replacing it but it hasn’t been replaced yet
<ikskuh> extern fn SDL_Init(…) callconv(.C) void;
<ikskuh> is the right syntax atm
<samtebbs> Ok thanks. I am getting a compilation error when using it though. error: invalid token: 'extern' for line `EFN_OVOID: extern fn () void,`
<samtebbs> Perhaps it can't be used in function types any more
<ikskuh> works for me
<ikskuh> ah
<ikskuh> in function types, you cannot mark a function as extern
<ikskuh> you *have to* state the calling convention
<ikskuh> <samtebbs> I don't care about the calling convention
<ikskuh> that's not possible for extern functions ;)
<ikskuh> they have a calling convention and your zig equivalent must match them
<samtebbs> ikskuh: That does make sense :) Zig format converts it to callconv{.C) so I'll keep it like that until I see any problems
<ikskuh> what function do you want to call?
<fengb> They don’t default to C call conv anymore?
<fengb> I need to get WASI tests running in CI :/
<ikskuh> @fengb: dunno actually, maybe they still do?
cren has quit [Remote host closed the connection]
layneson has joined #zig
foobles has joined #zig
<foobles> omg i realized the reason the branching code i was generating was giving me errors because I forgot to make the then/else blocks branch into the end block
<Dominic[m]> fengb not yet, but when it arrives! I want to be prepared though.
cole-h has joined #zig
xackus has joined #zig
marler8997 has joined #zig
<marler8997> I'm confused, I'm suddenly getting this error that Address.getOsSockLen is private, but I doin't see any recent changes around it ???
<marler8997> so given a *Address, how am I supposed to call bind without the length?
<fengb> There was a recent bug fix to make the compiler respect `pub` on methods
<marler8997> oh!!
<fengb> So... this could be a regression where we forgot to add pub
<marler8997> thanks fengb
<fengb> np
dnmllr has joined #zig
<marler8997> 23 seconds to build zig now...so glad I got this new machine
decentpenguin has joined #zig
ifreund1 has joined #zig
ifreund has quit [Ping timeout: 246 seconds]
plumm has joined #zig
r4pr0n has joined #zig
dnmllr has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<samtebbs> fengb. marler8997 I'm seeing that with StackIterator.next as well
dnmllr has joined #zig
<fengb> There's probably quite a few of these regressions. Probably best to make a PR
ifreund1 has quit [Ping timeout: 258 seconds]
daex_ has joined #zig
daex has quit [Ping timeout: 260 seconds]
ifreund1 has joined #zig
ifreund1 is now known as ifreund
daex_ is now known as daex
dddddd has joined #zig
Akuli has joined #zig
rzezeski has joined #zig
r4pr0n has quit [Quit: r4pr0n]
samtebbs has quit [Remote host closed the connection]
<oats> are function parameters only ever const?
<ifreund> oats: yep
<oats> huh, that's a bit irritating
<oats> ah well
<ifreund> though they can point to mutable things of course
<oats> sure
<ikskuh> oats: uncommon, but allows some neat optimizations
<ifreund> makes things more readable too imo
<ifreund> you want them to be const like 99% of the time
<ifreund> so you expect them to be const 100% of the time, and when they aren't const it needs to be explicit
<oats> makes sense
<ifreund> zig requires you to define a new local variable, which meets that requirement
<oats> props to whomever added testing.expectEqualSlices()
* oats taps temple
<oats> good stuff
drp has quit [Read error: Connection reset by peer]
<marler8997> Looking at lib/net.zig, I see that tests are pulled out into another file, net/test.zig
<marler8997> is this a new pattern? an old pattern? when should tests be put in the source file or pulled out into another?
<scientes> not important
<fengb> I think more complex/in depth test cases are pulled out
chapl has joined #zig
pystub has joined #zig
chapl has quit [Changing host]
chapl has joined #zig
Spex_guy has joined #zig
<Spex_guy> I've been thinking a lot about optimizing coroutines. They present an interesting problem, in that they introduce a feedback loop between compile-time execution and the optimizer. The core of it is that the optimizer needs to be able to reduce the size of the frame struct for an async function (possibly to zero), but comptime code is allowed to
<Spex_guy> check the size of the frame and do arbitrary things with it. At first it seems like you could run the optimizer to completion on parts of the code before executing other parts that are dependent on the result of the first, but this doesn't work. It would make things like mutual recursion between async functions with a heap allocator for frames
<Spex_guy> impossible to compile due to circular dependencies. Instead what we will need is a way to run optimization passes and comptime resolution passes iteratively to handle these cases. This will ultimately mean that we can't put a hard separation between the optimizer and the comptime execution engine, and probably that we'll need our own optimizer
<Spex_guy> that isn't LLVM. Is that something that you guys have thought about? Am I missing something?
ifreund has quit [Ping timeout: 272 seconds]
ifreund has joined #zig
ifreund has quit [Ping timeout: 240 seconds]
ifreund has joined #zig
Patrice_ has joined #zig
frett27_ has joined #zig
moo has quit [Ping timeout: 256 seconds]
chapl has left #zig [#zig]
Patrice_ has quit [Ping timeout: 264 seconds]
moo has joined #zig
nikoala has quit [Quit: The Lounge - https://thelounge.chat]
Patrice_ has joined #zig
<ifreund> Spex_guy: I think you should put that in an issue if you haven't yet, don't want it to get lost here
frett27_ has quit [Ping timeout: 272 seconds]
<ifreund> I haven't spent too much time thinking about it, but what you say makes sense to me
<tdeo> whoa, clang already has _Nullable, _Null_unspecified, and _Nonnull qualifiers on pointers, and exposes them through the ast api, i'm going to try to add them to translate-c
decentpenguin has quit [Quit: decentpenguin]
<ifreund> that is very cool
<Spex_guy> ifreund I'll add it to the issue about teaching LLVM to optimize async.
Patrice_ has quit [Quit: Leaving]
nikoala has joined #zig
ur5us has joined #zig
moo has quit [Ping timeout: 240 seconds]
<tdeo> hmm, [*c] pointers should really be non-nullable
<ifreund> is that doable using these clang qualifiers?
<ifreund> that would honestly be amazing
<tdeo> i mean, [*c] being nullable makes it hard to do a lot with the clang qualifiers
<ifreund> right, I totally see that
slurpie has joined #zig
<ifreund> my question is more as to the strength of the clang qualifiers (i'm not at all familiar)
<tdeo> the gcc qualifier only works on function pointers, but the clang qualifier works for any pointer
<tdeo> on function parameters*
<tdeo> and i guess another meaning of "strength" is what they do to codegen, which is nothing in the case of the clang qualifiers
<tdeo> unlike __attribute__((nonnull))
<tdeo> which makes calling that function with a null pointer UB
<tdeo> and your compiler can delete your null checks
Ichorio has joined #zig
Ichorio has quit [Client Quit]
leeward has joined #zig
<leeward> Did the auto-generated standard library docs move? https://ziglang.org/documentation/master/std/ says Zig Version 0.5.0.
<dingenskirchen> no, the master branch build of it is just broken for reasons beyond my knowledge. more up to date would be the 0.6.0 version
<leeward> weird sauce
<leeward> maybe worth a bug report, a fix, or changing the link on https://github.com/ziglang/zig/wiki/FAQ#where-is-the-documentation-for-the-zig-standard-library
<leeward> Well, that didn't fix things. I'm porting a thing I wrote mid-0.5 to 0.6, and getting an error about `'misc/bits/syscall.h' file not found`
<leeward> And indeed I don't see a misc/bits/syscall.h anywhere in my zig source.
Akuli has quit [Quit: Leaving]
<leeward> Ahah, there was some cruft left over from the 0.5 installation in my lib directory.
<leeward> Well that was easy.
metaleap has quit [Quit: Leaving]
pystub has quit [Ping timeout: 256 seconds]
bheads has joined #zig
dermetfan has quit [Ping timeout: 260 seconds]
dputtick has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
ur5us has joined #zig
dimenus has joined #zig
st4ll1 has quit [Ping timeout: 260 seconds]
Spex_guy has quit [Ping timeout: 245 seconds]
dimenus has quit [Ping timeout: 260 seconds]
layneson has quit [Quit: WeeChat 2.8]
ifreund1 has joined #zig
ifreund has quit [Ping timeout: 246 seconds]
ifreund1 has quit [Ping timeout: 256 seconds]
foobles has quit [Remote host closed the connection]
mcf has quit [Quit: quit]
mcf has joined #zig
ur5us has quit [Ping timeout: 260 seconds]