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> Me: "Dang with the embedded data, this zig program is 1.6 MB. That's huge!"
<fengb> Also me: "Go hello world is 2 MB"
<andrewrk> woo I got mq32's RetrOS project running on my laptop just in time for handmade con booth tomorrow
<mq32> andrewrk: nice!
frmdstryr has quit [Quit: Konversation terminated!]
<mq32> i know the build of that project isn't the most sane, but right now: works for me *grin*
<andrewrk> I had to watch your video closely to see that you press F2 and then F5
<andrewrk> :)
<mq32> :D
<mq32> good that the video exists *grin*
<mq32> actually, all F-Key from F1 to F5 do "something"
<mq32> but most of that is printing "not implemented yet" on the serial console
<mq32> right now i'm working on the "project system", so saving and loading of games
<mq32> as soon as that works, things start to get more interesting, but i think that starfield splash is a great eyecatcher :D
doublex has quit [Ping timeout: 240 seconds]
<andrewrk> it really is
<andrewrk> is there a way to get back to the title screen?
<andrewrk> from the code editor
wootehfoot has quit [Read error: Connection reset by peer]
<mq32> no, i haven't thought of this :D
<mq32> it's meant to go back there from "page 1", but page 1 isn't implemented yet
<mq32> if you want to "patch" that in
bjorob has quit [Ping timeout: 265 seconds]
<mq32> there's the function handleFKey in main.zig
<mq32> change the switch prong for .F1
<mq32> .F1 => switchTask(.splash),
doublex has joined #zig
marijnfs has joined #zig
ForLoveOfCats has quit [Quit: Konversation terminated!]
marijnfs has quit [Ping timeout: 276 seconds]
marijnfs has joined #zig
doublex has quit [Ping timeout: 250 seconds]
doublex has joined #zig
lunamn_ has quit [Remote host closed the connection]
<AlexMax> How do i build and include resource files in a zig binary?
<AlexMax> like, .res files?
shakesoda has quit [Quit: Connection closed for inactivity]
<AlexMax> erm, i mean .rc files
<AlexMax> erm, not quite what i meant, i already have an .rc file and would like to work it into the build system
<AlexMax> maybe at some point in the future I'll switch to embedfile, but i'm trying to get the C program compiling with build.zig
<AlexMax> with no zig code (other than in build.zig)
<torque> I am not aware of another supported method of embedding arbitrary files/data, which is not to say no alternates exist
<torque> there's always objcopy
<AlexMax> the mingw equivalent would be to run `windres` on the rc file, generate an object file with it, and then link the object into the final program
<AlexMax> i believe the llvm tool is llvm-rc
<daurnimator> src/ir.cpp:18701 in ir_analyze_decl_ref. This is a bug in the Zig compiler.
doublex has quit [Ping timeout: 240 seconds]
doublex has joined #zig
muffindrake has quit [Ping timeout: 245 seconds]
muffindrake has joined #zig
<daurnimator> hrm. can't do .ReturnType on a bound function
<AlexMax> oh man that was painful
<AlexMax> llvm-rc doesn't run the preprocessor against .rc files, so i had to run the preprocessor, fix the file encoding because it was UTF16...because it's windows, of course it does stuff like that...then finally pipe that through to llvm-rc, then just add the object file to the build
<daurnimator> analyze.cpp:5201 in hash_const_val. This is a bug in the Zig compiler. (I think I'm hitting ZigTypeIdBoundFn)
_whitelogger has joined #zig
chemist69 has quit [Ping timeout: 246 seconds]
chemist69 has joined #zig
<daurnimator> How can I get an unbound function from a bound function?
Ichorio has joined #zig
Ichorio has quit [Read error: Connection reset by peer]
leeward has quit [Disconnected by services]
leeward has joined #zig
shakesoda has joined #zig
dimenus|home has quit [Ping timeout: 240 seconds]
traviss has joined #zig
_whitelogger has joined #zig
_whitelogger has joined #zig
jjido has joined #zig
_whitelogger has joined #zig
_whitelogger has joined #zig
FireFox317 has joined #zig
FireFox317 has quit [Remote host closed the connection]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<daurnimator> scientes: https://github.com/zwegner/faster-utf8-validator/blob/master/z_validate.c <== I feel like this is something you'd rewrite in zig
jjido has joined #zig
mahmudov has quit [Ping timeout: 276 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<gonz_> Hmm, is `std.meta.tagName` broken? I get a compiler crash when using it on a tagged union.
<gonz_> "The following command exited with error code 3221225477"
<gonz_> Possibly I'm misusing it but you probably wouldn't expect a compiler crash either way.
<gonz_> Using `std.meta.activeTag` on it and printing the result gives a reference to https://github.com/ziglang/zig/issues/557
<gonz_> Looking at the `activeTag` tests in the repo I can use it like that. It should be said I have nested tagged unions and that's probably why this is failing.
lunamn has joined #zig
jjido has joined #zig
jjido has quit [Client Quit]
m4ge123 has joined #zig
jjido has joined #zig
jjido has quit [Client Quit]
jjido has joined #zig
<mq32> overly verbose error type of the day: error.BufferLengthMustBeMultipleOfBlockSize
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
wootehfoot has joined #zig
jjido has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Cadey has quit [Quit: WeeChat 1.9.1]
traviss has quit [Ping timeout: 240 seconds]
jjido has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dimenus|home has joined #zig
<daurnimator> What's a word that means not-empty?
<mq32> what do you want to describe?
<daurnimator> an event that fires once a buffer has at least one item in it
<mq32> onAnyData?
<daurnimator> mq32: but it only fires on transition from 0 => some. Not on e.g. some => some+1
<mq32> onFirstData
<daurnimator> mq32: it can grow and shrink and grow.
<daurnimator> "first" makes it sound like it only fires once ever
<mq32> hmm
<mq32> what's the use case?
<daurnimator> an event that fires once a buffer has at least one item in it
<daurnimator> e.g. you might specify the not_empty callback, if you want to attempt to "flush" to the next piece of a pipeline
<Sahnvour> occupied ?
<mikdusan> onBeginData
<daurnimator> aside: has anyone figured out a nice pattern for "event" callbacks in zig code?
<daurnimator> I'm trying to come up with something where callbacks are zero cost if not specified
<daurnimator> i.e. use compile-time reflection
<mq32> hmm
<mq32> idea: use a callback struct
<mq32> pass callbacks as a "namespace"
<mq32> instead of a struct instance
<mq32> fn doStuff(data:var, comptime callbacks: type) void
<daurnimator> mq32: yep I've been trying to get that to work for like 30 mins
<daurnimator> mq32: 1st problem: how do you pass the instance to the callback? given that the struct type doesn't exist at the moment of creation of the callback function
<daurnimator> doStuff("blahblah", struct { pub fn onThing(self: whatGoesHere) !void { try foo(); try bar(); } })
<SyrupThinker> Would that be @Self() ?
<daurnimator> SyrupThinker: no. @This() refers to the current inner-most struct being defined
<SyrupThinker> And that doesn't work
<mq32> does that concept work for you?
<daurnimator> mq32: no.
<daurnimator> mq32: https://godbolt.org/z/Xeg92S <== more like this
frmdstryr has joined #zig
<mq32> you can just pass WHAT_GOES_HERE to NewTypeWithCallbacks as well :)
<daurnimator> mq32: I want WHAT_GOES_HERE to be the return result of `NewTypeWithCallBacks`
<mq32> huh
<mq32> it's about zero-overhead, right?
<daurnimator> yeah...
<mq32> otherwise you could just return MyType.Callbacks
<daurnimator> return from where?
<mq32> the type you return from NewTypeWithCallBacks could have a struct with optional function pointers
<mq32> but: i got to go
<daurnimator> yeah. but that would be overhead
<daurnimator> also that gets into a mess with async functions...
<mq32> i just tried, but you cannot pass generic functions :(
<daurnimator> mq32: indeed.
<daurnimator> I currently have an absurd solution I'm calling "inside out". let me try and make a sample
<mq32> :D
<mq32> send the example to me as a PN/query, i'm away for some hours
Michael007775 has joined #zig
Michael007775 has quit [Remote host closed the connection]
Michael0077 has joined #zig
<daurnimator> mq32: https://godbolt.org/z/v6UWcX
Michael0077 has quit [Remote host closed the connection]
<AlexMax> okay I added an issue for .rc file support in the build system
Michael0077 has joined #zig
Michael0077 has quit [Remote host closed the connection]
mahmudov has joined #zig
adamkowalski has joined #zig
<adamkowalski> How do I pass a multidimensional array as a series of slices?
<adamkowalski> I'm defining a matmul function which will take two matrices as well as an output matrix to be agnostic about allocation. I've built up a few matrices using the literal syntax. But those are arrays not slices. How do I pass them as slices?
<mikdusan> adamkowalski: `var slice = array[0..];`
<adamkowalski> I've treid that, but that only makes a slice of the outer array, how do you make that transitive
<adamkowalski> My signature looks like fn matmul(comptime T: type, a: [][]T, b: [][]T, c: [][]T) void {}
<adamkowalski> Thats the minimal example of what I want to do
<Snektron> adamkowalski: you should make some custom view tyoes
<Snektron> It depends on what you want to do
<Snektron> If you just wanna pass matrices as slices: use a 1d array instead, or use a slice of arrays
<Snektron> If you want a generic n-by-m matrix view, you should have a pointer, m, n, and row stride
Aransentin has joined #zig
<adamkowalski> So there is no syntax for casting something array like to a slice?
<adamkowalski> I thought the docs said that slices were the most preferable because they allow the most things to convert into them
<adamkowalski> I'm used to the C++ way of doing things where normally I would use templates and anything that conforms to the "matrix" interface (at compile time) would be allowed
<adamkowalski> Whats the idiomatic way of doing things in zig?
<shakesoda> adamkowalski: perhaps like this https://github.com/andrewrk/tetris/blob/master/src/math3d.zig#L4
<shakesoda> this is kind of a non-answer though, just example
<adamkowalski> That uses a custom matrix type
<shakesoda> oh, are you doing arbitrary matrix sizes
<shakesoda> looks like i didn't read context well enough
<adamkowalski> I like that, but it's not generic, I come from the machine learning world where we deal with arbitrary sized dimensions and arbitrary number of dimensions
<adamkowalski> You could have images which have width x height x color channel
<adamkowalski> You could have a batch of images so it's width x height x color channel x batch
<adamkowalski> and if you have a video there is a time axis too
<adamkowalski> I was hoping that nested slices give me the most freedom
<shakesoda> i would approach this as Snektron suggested, myself
<shakesoda> but maybe someone else has other ideas here :)
<Aransentin> Is it possible to comptime-omit a switch case in a switch?
<adamkowalski> Am I approaching this incorrectly though? I feel like it should be a pretty simple thing right?
<fengb> Do anonymous lists cast to slices?
<adamkowalski> I just want to do matrix multiplication between a couple matrices
<adamkowalski> But I want to be invariatnt to the element type, and the width/height of the matrices
<adamkowalski> I was gonna make it return `!void` since the types might not line up, and I could make the last parameter be an output parameter. Then I don't allocate, thats on you
<adamkowalski> https://github.com/andrewrk/tetris/blob/master/src/math3d.zig#L4 has the whole thing unrolled and specific to one size
<adamkowalski> If we use a inline for loop we should get the same idea, but works for different sizes
Srekel has quit [Remote host closed the connection]
doublex has quit [Ping timeout: 250 seconds]
jjido has joined #zig
doublex has joined #zig
<adamkowalski> How do you all approach problems that normally you would tackle with overloading? For example a matrix * vector = matrix, vector * matrix = matrix, scalar * vector = vector, scalar * scalar = scalar. Etc
<fengb> adamkowalski: biggest challenge with your code is that slices are just fancy pointers and can't hold memory. So when you need some runtime dynamicism, it breaks down if you want to use the stack
<shakesoda> adamkowalski: with separate functions
<shakesoda> rather, separate function names
doublex_ has joined #zig
<shakesoda> it makes this kind of code more verbose, but it's not the end of the world
doublex has quit [Read error: Connection reset by peer]
<adamkowalski> Well I just assumed i'm approaching this wrong since I'm coming from a Python, Julia, C++, D world where problems are approached in a certain way. I don't want to bring the baggage of those languages with me here, so I want to learn how to approach things in Zig
<adamkowalski> However, one thing that scares me about the different functions for differnet types approach, is that it seems like you get a combinatorial explosion of implementations which are all the same, except for the type signature
<adamkowalski> What happens once you introduce GPUs into the mix and you have a cuda matrix, a cuda vector and so on
<adamkowalski> Then you want to do the same for AMD so you write a OpenCL implementation
<adamkowalski> Don't we want interfaces (preferably static) that allow any type which models certain behavior to be allowed in those situations?
lupine has joined #zig
<fengb> To have memory space for these calculations, you probably want comptime data structures
<fengb> If you need it fully dynamic, it'll have to use an allocator of sorts
jjido has quit [Remote host closed the connection]
jjido has joined #zig
mahmudov has quit [Ping timeout: 276 seconds]
adamkowalski has quit [Ping timeout: 245 seconds]
adamkowalski has joined #zig
<adamkowalski> fengb I like that idea, but if I want an nd array I can actually probably take a compile time list of dimensions? Then you can allocate on the stack. Otherwise you can take a runtime list of dimensions and allocate on the heap?
<adamkowalski> Is there any work done with automatic differentiation? I want to have a "tape" which records all the operations that happen to the array. This is called the forward pass, then you can play the tape in reverse and use the chain rule to get the gradient (the backward pass)
<adamkowalski> What if we had a few different types? An nd array type which owns the memory. Then you can have an nd slice which is just a view into the backing memory. We don't really have a notion of lifetimes, so the slics will be a bit unsafe. I'm not sure how to implment indexing, since we don't have any sort of overloading so I guess I can make it a function?
adamkowalski has quit [Ping timeout: 252 seconds]
Ichorio has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<mq32> daurnimator: that's a weird solution :D
bjorob has joined #zig
jjido has joined #zig
frmdstryr has quit [Ping timeout: 240 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Snektron> adamkowalski, matrix vector, matrix matrix are equivalent
<Snektron> In fact for linear algebra type libraries i usually like to implement things as free standing functions (or in c++ using inheritance hacks)
<Snektron> So the vector type is actually just `fn Vector(comptime T, comptime N: usize) type { return Matrix(T, N, 1); }`
<Snektron> And any operations that you do on vectors are free standing functions
<Snektron> Basic aritmetic is the same so those can be members of the matrix struct
<Snektron> So you really only have cross and dot left
<Snektron> You could also implement those as members on the matrix struct, but static assert the matrix is in fact of shape N, 1
Yardanico has quit [Remote host closed the connection]
Yardanico has joined #zig
Yardanico has quit [Client Quit]
Yardanico has joined #zig