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/
<ikskuh> how does async and foreign callbacks work together?
<ikskuh> i have the situation of "zig calls c calls zig" where the inner zig function does a read/write syscall
<ikskuh> this will not work with evented i/o, correct?
<andrewrk> you can make it work but there will be a seam at the C ABI boundary. async is a calling convention and the C ABI does not support that calling convention
grayhatter has left #zig ["reasons"]
<andrewrk> you could, for example, put something on a queue and then tell the event loop to attend to it
<andrewrk> you can definitely make it work but there will be glue code at the C ABI boundary
<ikskuh> okay, good to know :)
<ikskuh> deferring a write should be doable, but a read?
<ikskuh> huh
<ikskuh> i think i hit a design error
<ikskuh> you cannot create an array of pointers to global vars atm
foobles has joined #zig
aerona has joined #zig
<ikskuh> andrewrk, i heard you were featured on the new xkcd *trololo*
satchmo has quit [Ping timeout: 260 seconds]
<andrewrk> lol
<ikskuh> original is here: https://xkcd.com/2309/
<pmwhite> "it's a language that takes C and makes it simpler...and programs aren't allowed to have bugs"
satchmo has joined #zig
karchnu has joined #zig
nephele_ has joined #zig
nephele_ is now known as nephele
marijnfs has joined #zig
layneson has joined #zig
layneson has quit [Ping timeout: 272 seconds]
marler8997 has joined #zig
<marler8997> does zig support changing the output format? i.e. elf/coff/raw?
<daurnimator> marler8997: there is a raw output; but only from build.zig. and it's *weird*
<marler8997> thanks for the direction, I'll see what I can find out
ur5us has quit [Ping timeout: 260 seconds]
doublex has joined #zig
stripedpajamas has joined #zig
ur5us has joined #zig
joey152 has quit [Remote host closed the connection]
wozeparrot has quit [Ping timeout: 258 seconds]
rappet has joined #zig
<foobles> made a PR / issue for making ir_assert, src_assert, and ir_assert_gen print the location of the caller on failure
<foobles> the redefined assert() macro does this, as well as zig_assert
<foobles> so it makes sense (and is super handy) do a similar thing with all of those
<blueberrypie> marler8997 look at ZigGBA for an example of raw
<marler8997> blueberrypie: thanks for the tip, will do
aerona has quit [Quit: Leaving]
bren077s has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
bren077s has quit [Quit: -a- IRC for Android 2.1.55]
stripedpajamas has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
foobles has quit [Ping timeout: 245 seconds]
slowtype1 has joined #zig
satchmo has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
satchmo has quit [Ping timeout: 260 seconds]
stripedpajamas has joined #zig
stripedpajamas has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
stripedpajamas has joined #zig
satchmo has joined #zig
satchmo has quit [Ping timeout: 246 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 272 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
drvirgilio has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 244 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 244 seconds]
satchmo has joined #zig
cole-h has quit [Quit: Goodbye]
dermetfan has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
B4s1l3 has joined #zig
B4s1l3 has left #zig [#zig]
stripedpajamas has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 252 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
dermetfan has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 246 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 272 seconds]
satchmo has joined #zig
xackus_ has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 252 seconds]
ur5us has joined #zig
satchmo has joined #zig
satchmo has quit [Ping timeout: 244 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
waleee-cl has joined #zig
satchmo has joined #zig
greenfork has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 265 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
hermier has joined #zig
satchmo has joined #zig
slurpie has quit [Ping timeout: 256 seconds]
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
ifreund has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
stripedpajamas has joined #zig
satchmo has quit [Ping timeout: 272 seconds]
satchmo has joined #zig
stripedpajamas has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
cren has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
dddddd has joined #zig
satchmo has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 265 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
<cren> Why do allocators need to be declared `const`? Like `const arena_alloc = std.heap.ArenaAllocator.init(std.heap.page_allocator);`
<cren> I mean the opposite, why can't they be declared `const`
<cren> The above line doesn't work because functions expect a `var`
satchmo has joined #zig
<ikskuh> because an allocation changes the content of the allocator
<cren> That makes sense. But then how come I can do `const alloc = &arena_alloc.allocator;`
waleee-cl has quit [Quit: Connection closed for inactivity]
<ikskuh> ah
<ikskuh> that is a const pointer to mutable data
<ikskuh> you may not change the address the pointer stores
<ikskuh> but you may change stuff at the pointers location
<alehander92> i wonder if `const->var` keyword can work
<alehander92> in a hypothetical syntax for a language
<ikskuh> wdym?
<cren> that just sounds like a pain to type alehander92
<alehander92> well, some way to be very explicit about stuff like this
<ikskuh> i don't understand what that should do
<ikskuh> specify the type
<ikskuh> const ptr: *i32 = …;
<cren> ikskuh: I think he means as a way to declare a const pointer to mutable data
<ikskuh> is imho explicit enough
<ikskuh> the point is, alehander92: that "const→var" isn't explicit enough
<ikskuh> because this may get veeeeery long
<ikskuh> const ptr: *const * * const * i32;
<alehander92> yeah, it was just a thought
<cren> is that a const pointer to a pointer to a pointer to a const pointer to i32
<ikskuh> yep
<ikskuh> thank god zig has sane pointer syntax :D
<ikskuh> and not the C way
<cren> why would you ever need to use that
<ikskuh> :D
<ikskuh> because #baddesign
<ikskuh> i had a triple pointer once
<ifreund> i like my pointers to be double const, makes me feel more secure :P
<ikskuh> but double-pointers are quite common
<ifreund> const int const *
<ikskuh> const ptr: *const const i32;
<ikskuh> ifreund: just join the east-const
<alehander92> hm, yeah this kind of syntax is probably better
<cren> alehander92: it's a nice idea though
<alehander92> no, i like it
<ifreund> i agree that east const is more consistent within C, but i still hate it
<alehander92> the thing is it makes sense in a language where somehow `const` and `var-ity` are on the same conceptual level
<alehander92> separated from the type somehow
satchmo has quit [Ping timeout: 260 seconds]
<ikskuh> ifreund: you will hate my code bases then
<ikskuh> alehander92: my proposal was to change pointer-cost and variable-const
<alehander92> hm, not sure if i know enough zig to get that
<cren> back to the original topic, anyway: why do I have to do two separate declarations to get an allocator? why not just `const alloc = &ar_alloc.init()` or something?
<ikskuh> not the actual proposal, but something like
<ikskuh> let ptr: *nonmut Data;
<ikskuh> cren: because that would be a pointer-to-temporary
satchmo has joined #zig
<cren> what thing is temporary there?
<ikskuh> "ar_alloc.init()"
_Vi has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
<cren> ah yeah that make sense
<cren> Why does `pub fn ArrayList` currently return an `AlignedArrayList`, is this because `ArrayList` is just an interface
<ifreund> i assumed it was just to avoid code duplication between the two
<ifreund> an implementation detail really
<ikskuh> yeah
waleee-cl has joined #zig
satchmo has quit [Ping timeout: 272 seconds]
<cren> oh
satchmo has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 246 seconds]
dimenus has joined #zig
satchmo has joined #zig
satchmo has quit [Ping timeout: 246 seconds]
dimenus has quit [Quit: WeeChat 2.8]
dimenus has joined #zig
satchmo has joined #zig
[rg] has joined #zig
alexnask has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
hooo has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
ifreund has quit [Ping timeout: 258 seconds]
satchmo has quit [Ping timeout: 246 seconds]
satchmo has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
xackus_ has quit [Read error: Connection reset by peer]
kronnus has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
satchmo has joined #zig
kronnus has quit [Quit: rcirc on GNU Emacs 26.3]
ifreund has joined #zig
satchmo has quit [Ping timeout: 260 seconds]
cren has quit [Ping timeout: 245 seconds]
nmeum has joined #zig
r4pr0n has joined #zig
Akuli has joined #zig
satchmo has joined #zig
slurpie has joined #zig
r4pr0n has quit [Remote host closed the connection]
st4ll1 has joined #zig
stripedpajamas has joined #zig
cole-h has joined #zig
layneson has joined #zig
stripedpajamas has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<ikskuh> huh
<ikskuh> i think i discovered a bug in std.json.Parser…
<greenfork> I want to wrap std.debug.warn function and insert 1 more argument to anonymous struct `fn log(comptime fmt: []const u8, args: var) void`. So I want to pass this argument `.{myarg, args.@"0", ...}` to warn, can I do that?
stripedpajamas has joined #zig
<ikskuh> .{ myarg } ++ args
<ifreund> ++ is magic
<greenfork> wow it works, thanks!
<fengb> C++
<fengb> C with magic
<ikskuh> C++.{magic}
Akuli has quit [Ping timeout: 264 seconds]
satchmo has quit [Ping timeout: 260 seconds]
cren has joined #zig
satchmo has joined #zig
stripedpajamas has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
doublex has quit [Ping timeout: 260 seconds]
doublex has joined #zig
wozeparrot has joined #zig
<[rg]> I noticed hello world from the docs has a bug, but I'm sure you guys know too, gonna try to set up a ppa for zig today
<[rg]> in other words if you need help on docs...
<cren> what's wrong with hello world on the docs?
dimenus has quit [Quit: WeeChat 2.8]
dimenus has joined #zig
doublex has quit [Ping timeout: 256 seconds]
<ifreund> nothing unless i'm missing something
<ifreund> [rg]: what's the bug?
<oats> anybody here used gnu readline with zig? any code samples I could peek at?
dermetfan has joined #zig
<[rg]> ifreund: false alarm? didn't work for me the other day
<[rg]> on a different distro, but still linux
<ifreund> [rg]: hmm, at a guess I'd say you were using 0.5.0 and tried the hello world from 0.6.0
<[rg]> error was file.* on print not allowed, sorry for the ambiguity, don't remeber
<[rg]> ifreund: that's probably it
dimenus has quit [Quit: WeeChat 2.8]
cren has quit [Remote host closed the connection]
foobles has joined #zig
Akuli has joined #zig
r4pr0n has joined #zig
layneson has quit [Ping timeout: 244 seconds]
[rg] has quit [Ping timeout: 258 seconds]
riba has joined #zig
satchmo_ has joined #zig
satchmo has quit [Ping timeout: 272 seconds]
layneson has joined #zig
doublex has joined #zig
layneson has quit [Ping timeout: 260 seconds]
layneson has joined #zig
r4pr0n has quit [Ping timeout: 240 seconds]
r4pr0n has joined #zig
dimenus has joined #zig
[rg] has joined #zig
stripedpajamas has joined #zig
stripedpajamas has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
stripedpajamas has joined #zig
salotz has quit [Read error: Connection reset by peer]
r4pr0n has quit [Remote host closed the connection]
metaleap has joined #zig
stripedpajamas has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
riba has quit [Ping timeout: 272 seconds]
r4pr0n has joined #zig
[rg] has quit [Ping timeout: 272 seconds]
<oats> Will a defer get run if std.process.exit() is run later in the function?
<oats> (/scope)
<ikskuh> oats: no
<oats> hmm, ok shoulda guessed
[rg] has joined #zig
<fengb> process.exit is noreturn. No coming back to Zig
<alexnask> If you love a process you will let it go
dimenus has quit [Quit: WeeChat 2.8]
[rg] has quit [Ping timeout: 256 seconds]
metaleap has quit [Quit: Leaving]
layneson has quit [Ping timeout: 272 seconds]
r4pr0n has quit [Quit: r4pr0n]
<pixelherodev> Any numbers on how the latest commits impact the stage2-parser-rewrite perf?
stripedpajamas has joined #zig
Akuli has quit [Quit: Leaving]
slowtype1 is now known as slowtyper
spacehare has joined #zig
<spacehare> qq: how do I cross-compile multiple zig files?
<spacehare> the build-exe command doesn't seem to accept more than one file at a time.
<spacehare> and the build command doesn't accept the -target flag.
<torque> build-exe should automatically pick up the zig files @import-ed by the main file
<torque> is your goal to output multiple executables as well?
<spacehare> I see.
<spacehare> I basically did `zig build-exe *.zig`, not realizing the main.zig had to be first.
<spacehare> also: how do I cast an integer to a smaller type?
<spacehare> in my case: u64 => usize?
<fengb> @intCast for a runtime safety check
<fengb> @as if you want a compile error if there's type narrowing
<spacehare> thanks!
<fengb> e.g. @as(usize, u64) would fail to compile on 32 bit systems
<spacehare> yeah, I has tried that previously, but since I'm cross compiling for my (32-bit) raspberry pi it wouldn't compile.
<fengb> Ah okay, @intCast is your friend then
<afontain_> oh
<afontain_> that's great
<tdeo> note that it's undefined behaviour to @intCast a number that won't fit like that
<tdeo> you can use @truncate if you want it to just max out
<fengb> Runtime checked illegal behavior*
<spacehare> I don't really care, I don't think the software I'm building would need to fit a larger number in there.
<spacehare> it's not even my software, to make matters worse -_-
<fengb> Gonna ship Zig for someone else?
<spacehare> no, I'm compiling some software I found on sourcehut.
dimenus has joined #zig
<spacehare> it's a notetaking utility.
<dimenus> is there a quick way to do a byte for byte comparison on a struct in zig?
<spacehare> trouble is, it's author evidently never tred compiling it on 32-bit platforms
<spacehare> s/tred/tried/
<dimenus> i'm doing @ptrCast([*]u8, &foo)[0..@sizeOf(@TypeOf(foo))]
<dimenus> same thing with bar
<fengb> dimenus: you can try `std.mem.asBytes(&foo)`
<fengb> And do mem.eql
<dimenus> of course we already have it
<dimenus> :)
<fengb> But keep in mind that memory for regular structs aren't well defined
<fengb> So padding or safety bytes could affect the result
<fengb> There's also std.meta.eql taht generates the correct field comparison
<dimenus> fengb: wouldn't padding or safety exist on all values of a type though?
<dimenus> i think std.meta.eql is what I want
<fengb> But not all safety will be the same. And padding might just use the old garbage that was never cleared
<fengb> I think it's consistent now, but it's not defined to be
<pixelherodev> spacehare: link me to that? :)
<spacehare> pixelherodev: the note-taking thing?
<BaroqueLarouche> urgh, packed struc bugs is biting me ☹︎ Mostly with packed struct inside packed struct
<pixelherodev> spacehare: yeah :)
<pixelherodev> BaroqueLarouche: yeah, same :(
<spacehare> pixelherodev: sure
<pixelherodev> Not often, but when it comes up it's annoying
ur5us has joined #zig
<pixelherodev> spacehare: thanks :)
<spacehare> pixelherodev: https://sr.ht/~gpanders/zet
<spacehare> np
<spacehare> It's a zettelkasten note-taking utility.
<spacehare> ..and darn, it crashes when cross-compiled -_-
<fengb> Michaël Larouche: that might be exposing a deeper bug
<fengb> I have a feeling they're all the same underlying cause
layneson has joined #zig
<BaroqueLarouche> yea me too
hooo has quit [Quit: Connection closed for inactivity]
<pixelherodev> spacehare: that program doesn't build natively either
<pixelherodev> It's not a cross-compilation failure
<pixelherodev> It's just buggy :(
wozeparrot has quit [Remote host closed the connection]
wozeparrot has joined #zig
[rg] has joined #zig
<companion_cube> https://lobste.rs/s/o0xtns/some_were_meant_for_c inb4 zig also fits that
layneson has quit [Ping timeout: 260 seconds]
<spacehare> pixelherodev: well, I was able to build it natively
<spacehare> pixelherodev: it needs some patching if you're building it on a 32-bit host :(
slurpie has quit [Ping timeout: 264 seconds]
satchmo_ has quit [Ping timeout: 260 seconds]
alexnask_ has joined #zig
dimenus|home has joined #zig
dimenus has quit [Killed (orwell.freenode.net (Nickname regained by services))]
dimenus|home is now known as dimenus
alexnask has quit [Ping timeout: 272 seconds]
Guest15338 has joined #zig
alexnask_ has quit [Ping timeout: 260 seconds]
_Vi has quit [Ping timeout: 260 seconds]
layneson has joined #zig
dermetfan has quit [Ping timeout: 265 seconds]
dimenus has quit [Quit: WeeChat 2.8]
dimenus has joined #zig
slurpie has joined #zig
dimenus has quit [Client Quit]
dimenus has joined #zig
satchmo_ has joined #zig
stripedpajamas has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
stripedpajamas has joined #zig
dimenus has quit [Quit: WeeChat 2.8]
dimenus has joined #zig
<dimenus> i'm having a a lot of fun working with wayland in zig