<oats>
is there a way I can tell zig not to optimize away a variable?
<oats>
eg, if it appears unused to the compiler
<g-w1>
std.mem.doNotOptimizeAway ;)
<oats>
lol that's an amazing solution
<oats>
I love it
<g-w1>
what does rm even do?
<g-w1>
is it cross-platform?
<oats>
rm?
<g-w1>
: [val] "rm" (val)
<oats>
huh, I've got no idea what's going on there
<oats>
I think it's "putting" `val` into the `rm` register
<oats>
still don't understand it though
hiljusti has quit [Ping timeout: 240 seconds]
<kiedtl>
How does one cast an integer to an integer type of a lower width while truncating bits that don't fit? (something like @intCast that never panics)
<g-w1>
@truncate
B767B has quit [Remote host closed the connection]
<cr1901_modern>
Is there a bitvector library for zig (didn't find one through GH search, doesn't mean it doesn't exist)? I want to do base-2 modular arithmetic.
<cr1901_modern>
I can create my own []u1 matrices if I must (without the packing optimization)
<daurnimator>
cr1901_modern: std.PackedArray ? or std.EnumSet ?
<kiedtl>
cr1901_modern: You could use a C library without too much of a hassle... I guess?
klltkr has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
xentec_ has quit [Quit: memento mori]
xentec has joined #zig
xentec has quit [Remote host closed the connection]
xentec has joined #zig
zenkuro has quit [Ping timeout: 240 seconds]
xackus_ has joined #zig
xackus has quit [Ping timeout: 252 seconds]
notzmv has quit [Ping timeout: 260 seconds]
<cr1901_modern>
ack I'll take a look
notzmv has joined #zig
<kiedtl>
What's the ziggiest way to iterate over an integer range?
VFEXrt has joined #zig
<daurnimator>
Use a while loop?
earnestly has quit [Ping timeout: 268 seconds]
<andrewrk>
using zig's general purpose allocator leak checker + rr-project to get a debugger to print information at the callsite of the leaked memory allocation: https://clbin.com/6t88D
<daurnimator>
oh cool; rr finally support amd: > Experimental support for AMD Zen-based CPUs was merged on September 18, 2020.
<kiedtl>
daurnimator: so 'var foo = 0; while (foo < max) : (foo += 1) {}'? I was hoping that zig had something like `for (0..1) |index| {}' that scoped the index var
notzmv has quit [Ping timeout: 246 seconds]
waleee-cl has quit [Quit: Connection closed for inactivity]
cole-h has quit [Ping timeout: 240 seconds]
VFEXrt has quit [Quit: Connection closed]
notzmv has joined #zig
[wtf] has joined #zig
riba has joined #zig
[wtf] has quit [Quit: [wtf]]
pretty_dumm_guy has joined #zig
earnestly has joined #zig
notzmv has quit [Ping timeout: 240 seconds]
riba has quit [Ping timeout: 260 seconds]
<daurnimator>
kiedtl: correct. many people have said the same thing
B767B has quit [Remote host closed the connection]
<marler8997>
is this expected, when I call an async function twice in a row, each call gets a new @frame() pointer, but when I call it multiple times in a loop, each call returns the same @frame pointer...?
<marler8997>
there's something really screwy with the async implementation at the moment
<fengb>
That sounds correct. Loops reuse the memory space because the stack is invalidated
<marler8997>
the stack is invalidated after every function call regardless of whether you call it in a loop
<marler8997>
I don't understand the lifetime of the memory pointed to by @frame()
<fengb>
@frame() is just a pointer to where you dump the frame
<marler8997>
but it's not a pointer to the stack is it?
<fengb>
When you do “var foo = async bar()”, that sets the frame onto the current stack
<fengb>
Depends on where you stick the async call
<marler8997>
can't be
<marler8997>
oh wait
<marler8997>
you're saying it reserved space on the stack while the async call is alive
<marler8997>
so if you returned from your current function where you called async, then the async frame itself would also be invalidated correct?
<fengb>
No, it reserves space when the stack is alive
<fengb>
After the block returns, that async frame is use after free
<marler8997>
"the block"?
<fengb>
The block where you assigned the async
<marler8997>
ah
ifreund has left #zig ["WeeChat 3.1"]
ifreund has joined #zig
<fengb>
There’s no hidden allocation happening. You need to manually hoist the frame outside of the loop
SimonNa has quit [Quit: Leaving]
<marler8997>
does the documentation say this? I was reading it and don't remember it saying that
SimonNa has joined #zig
iamanoob has joined #zig
iamanoob has quit [Read error: Connection reset by peer]
<fengb>
Hmm I don’t see anything
<marler8997>
yeah, but I think you're right, with that new nuget of understanding I'm able to solve this guys question on reddit now
<ifreund>
g-w1: is it really worth implementing in stage1?
<g-w1>
yes, someone on discord got confused again today, and i think its a pretty nice feature
jmercan has quit [Quit: leaving]
<g-w1>
it caught a bunch of stuff in the stdlib already
<g-w1>
im not gonna pursue it if i have to rewrite a bunch of stage1, but if its easy, ill do it
<ifreund>
I'd be very surprised if it was easy
<g-w1>
i think the issue is that the top level scope is a comptime scope in stage1 so everything is automatically a comptime scope
<g-w1>
i dont think its *that* hard
<g-w1>
then again, every time i have tried to fix stage1 before, i broke something else...
<ifreund>
yeah, many things that should be trivial in stage1 aren't
<ifreund>
and fixing that isn't really worth it when stage2 should self host in the next year at the current pace
<g-w1>
i think theres a trade off between making life better for others and driving yourself crazy
<ifreund>
I mean I won't tell you how to spend your time, but there are lots of other things to work on that won't get thrown out when we self host :P
pretty_dumm_guy has joined #zig
<g-w1>
ok, I think this is still kinda trivial, but i wont spend that much more time on it
<g-w1>
ok, got it down to a few cases! i think these are all valid cases where comptime can be eliminated because the return type of the functions is comptime (either comptime_int or type) https://clbin.com/WvRTE
<g-w1>
is this correct?
ifreund has quit [Ping timeout: 240 seconds]
<g-w1>
when I remove those 2 errors, stage1 can compile!
SimonNa has quit [Remote host closed the connection]
SimonNa has joined #zig
<marler8997>
are async frames pinned in memory?
<mq32>
yes
<mq32>
they are one reason for the pinned struct proposal
xackus__ has quit [Ping timeout: 240 seconds]
deb303 has quit [Ping timeout: 268 seconds]
B767B has quit [Remote host closed the connection]
deb303 has joined #zig
bitmapper has joined #zig
ifreund has joined #zig
ifreund has quit [Remote host closed the connection]
ifreund has joined #zig
riba has joined #zig
pretty_dumm_guy has quit [Quit: WeeChat 3.2-dev]
jmercan has joined #zig
Akuli has joined #zig
mikdusan has quit [Read error: Connection reset by peer]