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