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/
_Vi has quit [Ping timeout: 272 seconds]
ur5us has quit [Ping timeout: 265 seconds]
return0e has quit [Read error: Connection reset by peer]
return0e has joined #zig
ur5us has joined #zig
_whitelogger has joined #zig
<daurnimator> pixelherodev: yeah caught errors sometimes show up. https://github.com/ziglang/zig/issues/1923
dddddd has quit [Remote host closed the connection]
seoushi has joined #zig
<seoushi> So in c I used void pointers for generics/structs of any type. So in zig I can do ArrayList(*void) which works but I'm not sure that is the best option. The ArrayList doesn't know all the possible types it will contain. Is this still a "good" practice or is there a feature I'm missing out on?
<daurnimator> seoushi: see the allocator interface for how you might do that
<seoushi> I know how to do it. I'm just wondering if there is something better that I'm missing out on
<seoushi> or if that is pattern in zig a well
qazo has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
return0e has quit [Ping timeout: 265 seconds]
return0e has joined #zig
metaleap has joined #zig
ltriant has quit [Ping timeout: 265 seconds]
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen1 has joined #zig
dingenskirchen1 is now known as dingenskirchen
seoushi has quit [Ping timeout: 265 seconds]
_Vi has joined #zig
chrisb has left #zig [#zig]
metaleap has quit [Quit: Leaving]
meraymond2 has joined #zig
meraymond2 has quit [Remote host closed the connection]
_Vi has quit [Ping timeout: 272 seconds]
ur5us has joined #zig
return0e_ has joined #zig
<Snektron> seoushi, you could consider @OpaqueType(), or a union/tagged union if you know all types beforehand
qazo_ has joined #zig
qazo has quit [Ping timeout: 268 seconds]
qazo_ has quit [Ping timeout: 240 seconds]
qazo has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
_Vi has joined #zig
qazo has quit [Ping timeout: 265 seconds]
return0e_ has quit [Remote host closed the connection]
return0e_ has joined #zig
ltriant has joined #zig
ltriant has quit [Ping timeout: 260 seconds]
<betawaffle> i sorta wish there was a way i could constrain a function to not allow certain things, like stack usage.
<betawaffle> i also wish i could explicitly define a calling convention, forcing it to put arguments/return values in specific places
<mq32> custom calling convention?
<mq32> or just enforce a default one?
<mq32> hm
<mq32> sadly, my experiments with zig and godot are failing
<mq32> code compiles, but it will segfault at a place inside the engine i cannot locate
<betawaffle> mq32: custom, like being able to specify that my entrypoint function is called with arguments in registers X and Y
<mq32> so yeah, custom calling convention
<betawaffle> as an alternative to a "naked" function with inline asm that reads those registers into local variables
<betawaffle> (which incidentally may be spilled to stack, if i'm not careful)
<betawaffle> basically it'd be nice to be able to be confident in writing more things without asm
decentpenguin has joined #zig
<mq32> problem with calling conventions is that the code gets forced to a certain CPU arch
<mq32> zig code is pretty much CPU agnostic atm
<betawaffle> right, but it has all kinds of comptime things that make it feasible to tweak things, rather than right multiple implementations
mattmurr has left #zig ["User left"]
mattmurr has joined #zig
ltriant has joined #zig
mahmudov has joined #zig
<mq32> gruebite, i found another problem with Godot
ltriant has quit [Ping timeout: 265 seconds]
BaroqueLarouche has joined #zig
<mq32> huh
<mq32> zig has problems with following C abi when passing structs?!
<betawaffle> where the F is this coming from? https://gist.github.com/betawaffle/687f51bc3bf2f21f9fd6fed7f50ab82a
<betawaffle> i can't seem to build anything with zig anymore
TheLemonMan has joined #zig
dddddd has joined #zig
<TheLemonMan> mq32, a lot, the ABI is partially and incorrectly implemented
<betawaffle> weird... i thought i tried to switch that
<mq32> TheLemonMan, i noticed
<mq32> i'm stripping down a example to three files and ~50 loc
<TheLemonMan> mq32, there's already 4344 open
<mq32> good to know
<mq32> hah
<mq32> and i found a bug in zig build :D
<TheLemonMan> It really do be like that sometimes
<fengb> Does that mean LLVM isn’t actually i386 compatible?
<pixelherodev> Apparently, yes
<fengb> Also why is P4 targeting 386? I thought i686 is P2 architecture
<TheLemonMan> no
<TheLemonMan> you have to read some of the commits that thead to the use of lahf/sahf instead of pushf/popf
<TheLemonMan> "Pentium4" is a superset of "i686"
<fengb> Oh wait it’s only jzck’s version that targeted P4
mahmudov has quit [Ping timeout: 272 seconds]
metaleap has joined #zig
mahmudov has joined #zig
waleee-cl has joined #zig
<fengb> Great... now I want to output html and finish implementing my templating system
<companion_cube> yay for comptime templates, heh?
<fengb> Yeah, I got bored once I realized I needed actual logic for conditionals / loops
<mq32> a lot should be possible with comptime and no code-generation
<mq32> like "output this only if this condition is met"
<mq32> where condition is either a predicate function or a trivial comparison (true, false, >=,<=,==,!=)
<fengb> Yeah, but I still need an ast of sorts
<fengb> And that led to comptime allocators so I started a different project instead >_>
<mq32> why ast? ah well, comptime stacks are a thing too
<fengb> Because I need to store logic that requires runtime values
<fengb> Loops within loops and such
<fengb> I built a super basic tree and I realized I could leverage an object pool after I dropped the project
<fengb> So it's something I wanted to go back to... but that also means I'm never gonna finish anything :P
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<pixelherodev> It's undefined whether an if-unwrap is a copy, correct?
<fengb> It's currently always a copy, but that's not by design yes
<fengb> Er... it's currently never a copy*
<pixelherodev> Right, that's what I thoujght
<pixelherodev> s/j//
<pixelherodev> Trying to avoid accidentally relying on impl-defined behavior like that
<fengb> andrewrk has mentioned to manually do a copy if you want one, and use `if (foo) |*bar|` if you need it to be a reference
<pixelherodev> oh right, forgot you could do `*n`
<metaleap> keep running into friggin "Assertion failed at /deps/zig/src/analyze.cpp:nnn in foo_bar_baz" crashes
<fengb> Welcome to zig ;)
<pixelherodev> s/zig/unstable alpha status compilers/
<pixelherodev> Proposal: printing a member of a structure that is a `[]u8` via std.fmt should surround it with quotes and escape the insides
<pixelherodev> (If I propose something here, it's a half-baked idea I don't consider good enough to submit to GH)
MatrixBridge has joined #zig
MatrixBridge has left #zig ["User left"]
<fengb> We should introduce him to Zig style errors :)
BaroqueLarouche has quit [Quit: Connection closed for inactivity]
<companion_cube> not sure if it would work well for F#, fengb
<companion_cube> mixing effects and higher-order functions is hrd
<companion_cube> hard
BaroqueLarouche has joined #zig
mokafolio has quit [Quit: Bye Bye!]
metaleap has quit [Quit: Leaving]
mokafolio has joined #zig
return0e_ has quit [Remote host closed the connection]
return0e_ has joined #zig
return0e_ has quit [Ping timeout: 265 seconds]
Akuli has joined #zig
salotz has quit [Remote host closed the connection]
waleee-cl has quit [Quit: Connection closed for inactivity]
<SyrupThinker> pixelherodev: Addition: And add the ability to limit the printed length.
<SyrupThinker> It tried to print megabyte big buffers several times on me
marmotini_ has joined #zig
seoushi has joined #zig
marmotini_ has quit [Remote host closed the connection]
ltriant has joined #zig
_Vi has quit [Ping timeout: 272 seconds]
ltriant has quit [Ping timeout: 240 seconds]
marmotini_ has joined #zig
BaroqueLarouche has quit []
benjif_ has joined #zig
benjif has quit [Ping timeout: 268 seconds]
BaroqueLarouche has joined #zig
<fengb> Maybe I can write my fancy sexpr => html translator in Zig
wootehfoot has joined #zig
decentpenguin has quit [Quit: decentpenguin]
waleee-cl has joined #zig
jmiven has quit [Quit: reboot]
<pixelherodev> SyrupThinker, you can override it locally manually
<pixelherodev> I've done that for a couple stdlib functions temporarily while awaiting proper fixes upstream
jmiven has joined #zig
<SyrupThinker> I'm doing that, but you just made a "proposal" so I might as well tag along because its related
<pixelherodev> That reminds me of a hashmap patch I plan on finishing up soon and upstreaming
losinggeneration has joined #zig
dimenus has joined #zig
<dimenus> woo, got libsoundio working with libmpg123 in zig :)
return0e_ has joined #zig
<fengb> nice
lunamn_ has joined #zig
lunamn has quit [Ping timeout: 265 seconds]
return0e_ has quit [Ping timeout: 265 seconds]
<dimenus> i don't quite understand how channels work in libmpg though
<dimenus> i have what is supposed to be stereo audio, but i'm just reading the bytestream directly into both channels in libsoundio
unrahul has joined #zig
marmotini_ has quit [Remote host closed the connection]
<gruebite> mq32: i would love to collaborate. want to use my existing repo?
<gruebite> it can be renamed if necessary: https://github.com/gruebite/zigdot
<mq32> gruebite, right now we are blocked on the #4344
<gruebite> yep
<mq32> i wonder if we can make something that is like
<mq32> const Godot = @import("godot");
<mq32> pub fn godotMain(nscript: *Godot.NativeScript) void {
<mq32> nscript.registerClass(MyCustomNode, "Reference");
<mq32> }
unrahul has quit [Ping timeout: 260 seconds]
unrahul has joined #zig
_Vi has joined #zig
nikoala has quit [Ping timeout: 240 seconds]
ur5us has joined #zig
<dimenus> andrewrk: can i ask you a quick libsoundio question?
unrahul2 has joined #zig
BaroqueLarouche has quit [Quit: Connection closed for inactivity]
unrahul has quit [Ping timeout: 260 seconds]
BaroqueLarouche has joined #zig
unrahul2 has quit [Ping timeout: 260 seconds]
<andrewrk> dimenus, sure
<dimenus> maybe it's not a libsoundio issue (i'm a newbie when it comes to this), but essentially i'm expecting the audio to be interleaved as LRLRLR, but ultimately the only solution that's working is to pull down as many bytes as if the stream was stereo
<dimenus> and pack that into one channel
<dimenus> here's my repo: https://git.sr.ht/~dimenus/mpg
<dimenus> fyi, it's hardcoded to 48k hz for now
<daurnimator> dimenus: btw, libsndfile is brilliant as a C library. Might want to use that for all your codec support?
<dimenus> daurnimator: thanks for the tip, i'm using libmpg123 atm
Akuli has quit [Quit: Leaving]
<daurnimator> dimenus: that's still required for mp3
<dimenus> ah got it. i probably wouldn't use mp3 on things I build myself, this is just to finish up my breakout clone (https://learnopengl.com)
<dimenus> i'm almost done, just have text/audio to do
metaleap has joined #zig
<dimenus> andrewrk: I actually think I'm overwriting past where I should be in libsoundio
<andrewrk> dimenus, I think you can set the requested layout
<dimenus> in libmpg123 or soundio?
<andrewrk> dimenus, in libsoundio, set the layout field of your output stream before calling soundio_outstream_open
<andrewrk> dimenus, as for interleaved, the soundio API hides that from you with the "areas" struct
<dimenus> i get that, which is why it feels like my code SHOULDN'T work
<andrewrk> look carefully at how the examples use the SoundIoChannelArea struct. it abstracts away interleaved/separate channels
<dimenus> although, the step on the area is 4 bytes not 2
marmotini_ has joined #zig
<dimenus> andrewrk: I don't understand what you mean by hides it from me with the areas struct?
<dimenus> Are you saying that I can pass the same stream into all areas if it's interleaved and it will just work?
<andrewrk> if you do the math like it's done in the examples, with `areas[channel].ptr + areas[channel].step * frame` then it will work regardless of whether the layout is interleaved or planar
<dimenus> ah, yeah that's what i missed. I thought step would be two bytes so i just casted the ptr to an [*]i16 instead of [*]align(4) i16
<dimenus> thanks
marmotini_ has quit [Ping timeout: 268 seconds]
<dimenus> andrewrk: thanks, looping over works as expected now. Apologies for thinking I could ignore the example and just straight copy into the buffer. I now see that the two pointers are returned are only two bytes appart - so my situation just happened to work by happy accident
<andrewrk> no worries. it's a bit confusing
<andrewrk> that was the simplest abstraction I could come up with to handle all the different sound systems
<dimenus> i was trying to straight copy because i thought it would be faster, but if I can just set a non-default layout to do that
<dimenus> this also explains why i was getting so much static / garbage when I tried to implement it this way before (but without mapping the step)
<dimenus> because I was mapping samples two bytes out instead of 4
mahmudov has quit [Ping timeout: 265 seconds]
marmotini_ has joined #zig
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
mahmudov has joined #zig
<metaleap> using `builtin.TypeInfo` stuff: AFAICT whenever at least one arg of multiple in an `fn` is `var`, the `FnArg.arg_type` seems `null` for *all* args of the corresponding `Fn` descriptor.
<metaleap> just to confirm: is that always the case or are there exceptions?
ltriant has joined #zig
<metaleap> also cannot take such a func's address?! is that true or did i get a confused compiler msg..
_Vi has quit [Ping timeout: 252 seconds]
lunamn has joined #zig
lunamn_ has quit [Ping timeout: 265 seconds]
<SyrupThinker> metaleap: Well whats the message?
<metaleap> already gone, but sth like "cannot take addr of size-0 type"
<metaleap> only for ptrToInt of an fn with a `var` arg, when reverting to fully-typed no prob of course. wasnt a big need for var there tho, just had to try while at it
marijnfs has joined #zig
<SyrupThinker> Well I'd say thats a case of unhelpful compiler error
lunamn has quit [Read error: Connection reset by peer]
<SyrupThinker> Should probably say something like "cannot take address of var function"
<metaleap> it comes up for different situations, so would guess these situations all end up at the one code path
<metaleap> that raises it
<metaleap> probably going to need carrying-contextual-details-along logic in there sooner or later
<metaleap> for more differentiated msgs
<fengb> Ah yeah generic functions aren’t “real”. You’ll need to wrap it if you want to make a function pointer
lunamn has joined #zig
<SyrupThinker> Which mentions something I just wanted to point out :)
<SyrupThinker> const f: fn(u8) void = varf; // fn varf(t: var) void {}
<SyrupThinker> I'd expect that to work
<SyrupThinker> But it doesnt do a coersion
<SyrupThinker> Then you could also directly pass var functions to functions with a compatible signature
marijnfs has quit [Remote host closed the connection]
marijnfs has joined #zig
<metaleap> would be neat tbh. of course such a coercion would force-create the instantiation but that would be the intent in such cases anyway.
<metaleap> (if it didnt already exist, i mean that particularly-typed instantiation of the generic fn)
<fengb> Sounds like a proposal :P
<companion_cube> https://os.phil-opp.com/allocator-designs/ might be of interest here? :)
<fengb> Is there an integer equivalent to @fabs?
<fengb> math.absCast()
<Snektron> math.intAbs
marmotini_ has quit [Ping timeout: 268 seconds]
ur5us has quit [Ping timeout: 265 seconds]
mahmudov has quit [Remote host closed the connection]
wootehfoot has quit [Read error: Connection reset by peer]
marijnfs has quit [Remote host closed the connection]