<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…]
<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>
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
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?
<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>
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>
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?
<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]