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/
<pixelherodev> Okay, got the test passing!
<pixelherodev> Sort of
<pixelherodev> Leaks though :(
<andrewrk> vscode users, what's the equivalent of vim's `cc` ?
<andrewrk> erase current line. indent to correct level and leave cursor there
<pixelherodev> Okay, technically, if I disable leak testing, it works
<leeward> pixelherodev: And if you don't look for bugs, they don't exist!
<radgeRayden> works for COVID testing
<pixelherodev> Would be awesome if the testing_allocator gave a trace for allocations that aren't freed
<ifreund> isnt there a vim mode for vscode?
<fengb> Oh hey there’s an organic HN post on Zig
<leeward> They always say you get what you measure. Who wants bugs? Why measure for those?
<leeward> nifty
aerona has joined #zig
<pixelherodev> Wait, did I miss a showtime?
<andrewrk> ya, 6 hours ago
<pixelherodev> Gotcha
<pixelherodev> I'll have to wait for the upload then :P
<pixelherodev> What's a good way to debug memory leaks in stage2? <- andrewrk
<fengb> It’s available on Twitch directly
<pixelherodev> fengb: yes, but that means using Twitch
<pixelherodev> Which I avoid wherever possible :P
<andrewrk> pixelherodev, remember last time? -Dforce-link-libc and then valgrind --leak-check=full
<pixelherodev> Right, thanks!
<fengb> Cause YouTube is so much better >_>
<pixelherodev> Forgot that -Dforce-link-libc is a thing
<pixelherodev> fengb: no
<pixelherodev> but MPV is
<pixelherodev> ;)
<andrewrk> or, you know, help me finish GeneralPurposeDebugAllocator :P
<pixelherodev> andrewrk: ... yeah, uh... well...
<pixelherodev> :P
<pixelherodev> Wait, actually
<pixelherodev> andrewrk: does std.testing._allocator work with -Dforce-link-libc
<torque> mpv can play videos from twitch
<torque> it just uses youtube-dl which supports a whole lot more sites than youtube
<pixelherodev> ... nope, doesn't work, drats
<pixelherodev> torque: huh.
<pixelherodev> Good to know
<pixelherodev> Anyone mind dropping the link?
<pixelherodev> :P
<torque> first hour is pre-show
<mq32> andrewrk: do you have the headset i use as well?
<andrewrk> mq32, yes I bought it on your recommendation :)
<mq32> happy with it?
<andrewrk> yep seems to do the trick
<mq32> USB brings a huge quality boost and it's really comfy and lightweight
_Vi has quit [Ping timeout: 246 seconds]
<pixelherodev> ... wow, showtime is biiiig
slurpie has joined #zig
* pixelherodev casually sets aside 4.5GiB of tmpfs for it
<fengb> Probably the raw feed
<pixelherodev> Ughhh, forcing test with libc results in unrelated crash
<andrewrk> you know what would be a slick completion? when you switch on an enum, it would create dummy switch prongs for all the enum values
dongcarl has joined #zig
doublex has quit [Read error: Connection reset by peer]
doublex_ has joined #zig
<pixelherodev> andrewrk: okay, how would you suggest debugging memory leaks in stage2 *tests*?
<andrewrk> copy paste the test case into a file
doublex_ has quit [Read error: Connection reset by peer]
<pixelherodev> It's incremental though
doublex has joined #zig
<andrewrk> to answer your question I would be going through the same thought process as you
<andrewrk> I'm sure you can come up with something
<pixelherodev> I'm probably just going to step through the code with GDB and see what I changed
doublex_ has joined #zig
doublex has quit [Ping timeout: 246 seconds]
<andrewrk> pixelherodev, I need to add sse registers (xmm0-xmm15) to x86_64.Register
<andrewrk> can I put them at the end?
doublex_ has quit [Ping timeout: 260 seconds]
<pixelherodev> Yeah, probably?
<pixelherodev> Wait wow
<pixelherodev> You're adding SSE support?
<pixelherodev> hmm
<andrewrk> it's part of the C ABI for passing floats
<pixelherodev> Right I know
<pixelherodev> I have the C ABI partly implemented in the other PR
<pixelherodev> I had SSE classification in there too
<pixelherodev> andrewrk: do you want me to push this test case to the side and get the PRs done *now* so we can avoid duplicating work?
<pixelherodev> Can always add this case in as a different PR
<andrewrk> what are you trying to work on?
<pixelherodev> I was just cleaning up the test harness PR, but only because it's a blocker to the function call with params one
<andrewrk> I'm working towards getting my test case to work: https://clbin.com/dw3Fg
<pixelherodev> I've got integer parameters implemented fully, and SSE classification (but not the actual passing / receiving of them)
<pixelherodev> The one from the commit a few days back?
<andrewrk> yeah
<pixelherodev> I got up to the addition impl
<pixelherodev> I can probably get that done tonight if you want
<andrewrk> I'm doin it now
<pixelherodev> The whole test I mean
<pixelherodev> AH
<pixelherodev> Ah*
<pixelherodev> Do you want to merge my function parameters branch so you can move past that?
<pixelherodev> If so, it'd only take me ~five minutes of work to get it presentable, so to speak
<andrewrk> sure I'd be happy to look at it
<pixelherodev> The only blocker is the test harness one, so I'll just not bother adding in the new test yet
<pixelherodev> I'll have to redo those as a separate PR later, but no biggie
<pixelherodev> Just stashed the changes for later :)
<pixelherodev> andrewrk: mind taking another look at the test harness one?
<pixelherodev> #5708
<shcv> what's the right way to do default values for a type constructor? I'm trying to make an array tree with a customizable number of entries per node, but defaulting to @bitSizeOf(usize)
<shcv> Or should I make two versions of the constructor function, one with the parameter and one that wraps it to provide the default?
<andrewrk> shcv, that's what std.ArrayList does
<pixelherodev> andrewrk: oh yeah, the only real blocker for the function params PR is parameter lookup in Zig source
<shcv> are allocators expected to provide zeroed memory, or undefined?
<shcv> I guess a better question is whether I need to explicitly fill an ArrayList with my tagged union's 'Empty' values, or if initCapacity() is good enough?
doublex has joined #zig
<andrewrk> allocators provide undefined memory
<andrewrk> pixelherodev, I'm looking now
doublex_ has joined #zig
<pixelherodev> andrewrk: heads up that the integer parameter one is based on the zig-test-harness one
<pixelherodev> So the test harness changes need to be merged before the parameter one ca be done
<pixelherodev> can*
<pixelherodev> s/done/finalized
<shcv> what's the best way to initialize an ArrayList with N "Empty" values then? while(i < size) : (i += 1) { list.append(Node.Empty); } ?
<shcv> hmm, just noticed the appendNTimes; that's probably it, unless anyone has a better suggestion
marijnfs has joined #zig
<andrewrk> pixelherodev, test-stage2 passing for you locally?
<pixelherodev> Yeah?
<pixelherodev> For the test harness one
<pixelherodev> Let me double check real quick
<pixelherodev> Yep!
marijnfs_ has quit [Ping timeout: 260 seconds]
<pixelherodev> andrewrk: let me quickly make those changes
<pixelherodev> :)
<pixelherodev> ... I'd use ZLS renaming but I have no idea how yet :P
<pixelherodev> Okay, just need to run tests again...
<pixelherodev> Got it!
<pixelherodev> andrewrk: done :D
<andrewrk> nice work
<pixelherodev> andrewrk: did you do parameter lookup on your branch yet?
<andrewrk> do you mind if I squash
<pixelherodev> No?
<pixelherodev> I mean, why would I?
<pixelherodev> Some of them definitely should be squashed (the last 3 -> "cleanup")
<pixelherodev> Though some I think make sense on their own, as distinct changes
<pixelherodev> It's not a big deal either way to me
<pixelherodev> Okay perfect
<pixelherodev> Now to rebase the other one
<pixelherodev> Okay, all that's left is parameter lookup / Zig source
nephele_ has joined #zig
nephele has quit [Ping timeout: 260 seconds]
nephele_ is now known as nephele
<pixelherodev> andrewrk: did you do parameter lookup on your branch yet?
<andrewrk> almost done with that
<pixelherodev> Neat
<andrewrk> oh you mean AST -> ZIR?
<pixelherodev> Yeah
<pixelherodev> I did it for my branch already for ZIR
<andrewrk> no, I'm in codegen.zig rn
<pixelherodev> Ah
<pixelherodev> Wanna just steal my work? :P
<andrewrk> yeah sure
<pixelherodev> #5411
<andrewrk> wait what, how has this been open since May?
<pixelherodev> Ah, because I reused the branch lol
<pixelherodev> I did the fn(args)void PR back in may
<pixelherodev> but it blocked on the test harness
<pixelherodev> So I re-did it generalized yesterday and force pushed :P
<andrewrk> in my approach, an array of MCValues are precomputed for all the parameters, and genArg is just return self.args[inst.args.index]
<pixelherodev> I think this is better, because it means unused args aren't given MCValues
<pixelherodev> and there's no real reason that arg(N) should be used multiple times for the same value of N
<andrewrk> I think it will result in doing the classification of parameters multiple times though
<andrewrk> plus you have to split values into multiple registers
<pixelherodev> I already have the beginnings of that, but your way would probably do it better
<pixelherodev> DUAL_INTEGER means use two registers - e.g. u128, or slices would use it
aerona has quit [Read error: Connection reset by peer]
<pixelherodev> I was going to work on slice passing immediately after this PR was done
<pixelherodev> andrewrk: I would highly recommend stealing the register shuffling bits at least
<pixelherodev> There's a few useful commits in there regardless
<andrewrk> I'll take a look
<andrewrk> does ZLS have the ability to run `zig build` and put red squiggles in the editor?
<pixelherodev> Which editor?
<pixelherodev> I have that with Kakoune, but not from ZLS
<andrewrk> vscode
<pixelherodev> No idea, sorry
<shcv> is there any notable difference between a void tagged union and an optional?
radgeRayden has quit [Ping timeout: 272 seconds]
<andrewrk> shcv, no, those are conceptually the same
<andrewrk> only difference is syntax really
<pixelherodev> andrewrk: should i close my PR for function args?
<andrewrk> I'm referring to it, but also doing things a bit differently
<pixelherodev> I mean, I can close the PR but leave the branch as is
<pixelherodev> Maybe I should work on comptime or something instead ;)
<andrewrk> cool, I made it so that in codegen.zig basically all the functions have comptime access to std.Target.Cpu.Arch, but if the function doesn't need that value, then it doesn't cause bloat
stripedpajamas has joined #zig
oats is now known as oa
oa is now known as oats
aerona has joined #zig
creationix has joined #zig
<creationix> Hello zig peeps!
<shcv> why can't I do a binary negation of a comptime_int?
<shcv> and I didn't really need it to be comptime anyway...
<torque> probably because a comptime int doesn't have a specific bit representation?
<creationix> shcv: Are you specifying a concrete type like u32?
<shcv> I did for the original value; const index: i8 = 4;
<shcv> but then I'm trying to compute ~-2^index
<shcv> which admittedly may not be what I want exactly, but I'm trying to figure that out
<creationix> maybe one of the intermediate values needs to have an explicit type. I just got bit by a similar issue in C.
<shcv> I think the problem was the operator precedence
<creationix> that could do it too :D
<shcv> I needed ~-(2^index) instead
betawaffle has quit [Ping timeout: 264 seconds]
<marler8997> dang, alignment broke on wasm page allocator
betawaffle has joined #zig
<fengb> Oh?
<marler8997> yup
<marler8997> fixing...
<marler8997> though, it could have been broken before...not sure
<creationix> I'm trying to manually port this algorithm to zig (I know it's not fast and probably has timing attacks, I just want it functional) http://ed25519.cr.yp.to/python/ed25519.py
<creationix> I see ** being using for exponation, but can't find if zig has a corresponding operator for integers.
<torque> you probably want std.math.powi
<torque> though since almost all of those are 2 to a power you could also just use left shifts?
<creationix> good point, I just realized that.
<creationix> I'm not sure std.math.powi would keep my value comptime
<creationix> leftshift might
<shcv> is there a better way to do twos complement negation than casting to and from a signed integer? I'm really just trying to make a mask where all the bits less than an index are 1...
<creationix> hmm, python made this look a lot simpler than it really is. Arbitrary precision integers (or at least up to 256 bit) with built-in exponent modulus.
<shcv> a utility for casting between signed and unsigned versions of the same int would be nice
<shcv> mostly I see @bitCast(std.meta.Int(true, bit_count), value) in std
<shcv> well, false is more common
<shcv> ok; I figured out a better way to get what I want without twos-complement or signed integers, but I still think toSigned and toUnsigned would be handy
<creationix> schv why not `(1 << num) - 1` ?
<creationix> *shcv ^
<shcv> yeah; that's what I figured out
<shcv> took me a while; I'm probably getting tired
<creationix> is there a way in zig to see what type the compiler assigned to a value? I tried printing @TypeOf, but it just logs `type`
<shcv> I ran into that yesterday; you want @typeName(@TypeOf(value))
<creationix> lol, I just figured out the same thing
stripedpajamas has quit [Quit: sleeping...]
<creationix> hmm, they are all just `comptime_int`
waleee-cl has quit [Quit: Connection closed for inactivity]
<andrewrk> hi creationix
<creationix> hi Andrew!
<andrewrk> @compileLog
<andrewrk> @compileLog(@TypeOf(value))
<creationix> oh nice
<fengb> marler8997: Ah yeah, at the time I think andrewrk mentioned it’s okay for the page allocator to not align. Although I probably should have added a check and return OOM
<wilsonk> andrewrk: if you didn't find a way to use 'cc' as "delete current line and put cursor at correct indentation in insert mode", then there is a way to do it if you are using VSCodeVim. I added { "before": [ "<leader>", "c", "c" ], "after": [ "^","C" ] } to user settings and it seems to work (you need the <leader> in there for correct behavior unfortunately). It may just be easier to use "^","C" depending on your typing style :)
aerona has quit [Read error: Connection reset by peer]
stripedpajamas has joined #zig
<marler8997> fengb, gotcha, well hopefully with that PR it's aligning properly now
<marler8997> wasm page size is 64K so it was unlikely that someone would hit this
<marler8997> I'm curious why u29 was picked for the maximum alignment size...
<andrewrk> marler8997, inspired by http://llvm.org/docs/LangRef.html#id200
doublex has quit [Remote host closed the connection]
<andrewrk> this type/upper bound should be revisited before 1.0
doublex has joined #zig
shcv has quit [Ping timeout: 244 seconds]
stripedpajamas has quit [Quit: sleeping...]
knebulae has quit [Read error: Connection reset by peer]
swills has quit [Ping timeout: 258 seconds]
swills has joined #zig
waleee-cl has joined #zig
dermetfan has joined #zig
antaoiseach has joined #zig
<antaoiseach> Hello folks, I have a small question about `defer`'s behaviour in a small snippet - https://paste.rs/NeM
<antaoiseach> In this contrived example, I'm creating a node inside a `while` loop, append to a list, and then defer-ing its destruction (all within the while loop).
<antaoiseach> My question is - why is the defer not getting triggered once the `while` loop's scope is left?
dddddd has quit [Ping timeout: 260 seconds]
<dermetfan> antaoiseach: it seems to me like it is triggered. I checked by inserting log statements in the defer: https://godbolt.org/z/SLdQJK
st4ll1 has quit [Ping timeout: 265 seconds]
alexnask has joined #zig
<danyspin97> Will it be possible to use mesonbuild with zig?
<ifreund> I don't think zig does anything that would make that impossible
<ifreund> support would be needed from the meson side most likely however
<danyspin97> I see
<danyspin97> however if zig devs don't actively work on it, it would end up as D support imho
ofelas has joined #zig
<antaoiseach> dermetfan: let me check that... thanks for checking the code out! :-)
<ifreund> danyspin97: zig's own build system and the language itself are not stable yet, so active work to support for other build systems is pretty far down the line atm
<antaoiseach> dermetfan: so the question now is - why doesn't using the nodes give an error now?
<ifreund> you should totally open an issue explaining why this is important to if you want to see it happen though
<antaoiseach> I also tried `list.destroyNode` directly without defer, and that still did not trigger a use-after-free
<antaoiseach> I'm confused!
<danyspin97> ifreund: I see, thanks for the explanation
<ifreund> antaoiseach: because the memory is not free'd until you deinit() the arena
<daurnimator> creationix: what you working on? :)
<antaoiseach> ifreund: I had a suspicion that that was the case ... but doesn't this make it difficult to reason about when freeing is actually done?
<antaoiseach> Thanks for the confirmation though! :-)
<ifreund> antaoiseach: this is just how arena allocators work, no changing it really
<antaoiseach> Hmmm
<ifreund> like all allocators they have their upsides and downsides
<daurnimator> antaoiseach: the arena allocator never reuses memory
<daurnimator> antaoiseach: though ifyou run under valgrind, you will see all the issues
<antaoiseach> ifreund: daurnimator: Thank you! That does make sense .... so if I did not know how much text I would (say) read into an arraylist, which allocator would you recommend? `c_allocator`?
<ifreund> depends on how long the array list will be around
<ifreund> if its freed right after you finish reading then an arena is a good choice
<antaoiseach> or I could still use Arena+page_allocator if I didn't care about the objects being freed till the end?
<antaoiseach> ifreund: Aha
<daurnimator> antaoiseach: use the most relevant allocator for your situation. if the lifetime of the items is known and soon, an arena allocator is correct....
<ifreund> if it hangs around for the lifetime of your program then a general purpose allocator might be a better choice
<antaoiseach> Hmmmm ...
<antaoiseach> Thanks again, ifreund and daurnimator - I think yes, for my use case, arena would suffice nicely
<antaoiseach> Just one more follow-up question though - is page_allocator okay to be paired with arena? or is there a better allocator (no fixedbuffer)
<ifreund> also depends on how long your program lives. If its a one-shot command line tool an arena might be fine for the whole program
<daurnimator> antaoiseach: sure. many allocators are intended to be composable
<ifreund> if you're writing a server, then definitely not
<ifreund> page_allocator is fine yes, though if you're already linking with libc then the c_allocator might be faster
<ifreund> we don't have a pure zig general purpose allocator yet
<daurnimator> yet :)
<antaoiseach> Haha ... yes, that came up in the showtime yesterday as well! :-)
<daurnimator> I was looking for a project to work on tonight; but I don't think I have the mental energy for an allocator :(
<antaoiseach> hahaha
<antaoiseach> Okay, I think my mind's made up to go with arena+page_alloc for now ... thanks again, guys! Cheers! :-)
<ifreund> no problem
antaoiseach has quit [Quit: leaving]
waleee-cl has quit [Quit: Connection closed for inactivity]
nikita` has joined #zig
drewr has quit [Ping timeout: 260 seconds]
drewr has joined #zig
stripedpajamas has joined #zig
<alexnask> Has anyone had issues when freeing strings allocated by the page allocator?
<alexnask> I get assertion fails about the alignment of the memory
<alexnask> I should probably make a small repro
<nerthus> if zig is to have a package manager, can we avoid Rust's mistake and add namespaces?
<nerthus> (to the package database, not the language itself)
<daurnimator> nerthus: that question is pretty far down the line right now
<nerthus> meaning it's further in the future or like unwarranted?
<daurnimator> nerthus: meaning there's like 10-20 decisions that need to be made before your question even makes sense to ask
<nerthus> hmm, I disagree. It's quite fundamental in package management and should be decided early on imho
<nerthus> but alright :)
<nerthus> I just fear for a Zig swmon situation
<gonz_> alexnask: It seems maybe `zls` main branch isn't set up for the `@asyncCall` change...?
<alexnask> I just updated it
<alexnask> I will push soon
<alexnask> It seems like the new allocator interface broke something though (I think it may be readFileAlloc)
<alexnask> So I have to fix that first
<alexnask> err, readAllAlloc I mean
<gonz_> Coolcool
<mq32> heyah
<mq32> at first, i was sceptical towards directory handles…
<daurnimator> mq32: morning!
<mq32> now i miss them in pretty much any language
<mq32> hey daurnimator
<daurnimator> mq32: good news(ish): they exist in almost every language; but mostly discarded and ignored
<mq32> Qt has QDir, which is kinda a directory handle but not :D
<mq32> would neet to use posix/windows API for that manually or pull in a non-qt library
<alexnask> I think `std.ChildProcess.exec` is broken with the page allocator with the new interface FeelsBadMan
<alexnask> readAllAlloc is for small buffers too I believe. I guess I should fix them in std instead of bitching
<alexnask> gonz_, Should build and run fine on master now
<gonz_> Hmm, I'm getting a build error; `AccessDenied`
<alexnask> That will happen if the zls executable is still running when yo uare building ;)
<alexnask> (assuming you are using it directly from the cache)
<gonz_> Ugh, yeah
<alexnask> Let me know if it works fine btw, I think I removed all the problematic (aka segfaulting parts) :P
dddddd has joined #zig
layneson has joined #zig
layneson has quit [Ping timeout: 246 seconds]
slurpie has quit [Ping timeout: 256 seconds]
antaoiseach has joined #zig
stripedpajamas has quit [Quit: sleeping...]
layneson has joined #zig
antaoiseach has quit [Quit: leaving]
layneson has quit [Ping timeout: 265 seconds]
Aransentin has left #zig [#zig]
blinghound has joined #zig
waleee-cl has joined #zig
<creationix> daurnimator: at the moment, I'm just trying to get a clean port of libhydrogen to zig and wasm. I'm working on some decentralized protocols that need to run everywhere (microcontrollers, browsers, etc) and need the basic crypto primitives in it.
Aransentin has joined #zig
antaoiseach has joined #zig
<blinghound> Just wondering if anyone can help me out here
<blinghound> I'm trying to increment a number at compile time to assign to comptime struct members
<blinghound> I'm not sure if it's even possible yet
<alexnask> Comptime fields cannot be modified
<alexnask> Theres an issue up for that
<alexnask> However there is a trick
<blinghound> ohhhhhhhh thank you
<alexnask> For "comptime closures"
<alexnask> Let me write a simple example
<blinghound> awesome thanks!
<antaoiseach> Hello folks, in Rust we can convert a Vec into a []T. Do we have a similar situation in Zig? My usecase is this - I want to use, say, an arraylist/linkedlist as my data structure, but want to return a []const u8 (say) ... any easy/existing way to do this? I don't want to type my API type to a specific type like ArrayList or SinglyLinkedList
<blinghound> @antaoiseach .toOwnedSlice
<blinghound> or .toSlice
<blinghound> I believe
<antaoiseach> blinghound: lemme hit that up and get back
<blinghound> if you use .toOwnedSlice, the caller has to free the memory, the ArrayList won't control the memory after calling it
<antaoiseach> blinghound: Thanks for that! I checked the code for it ... yes, you're right ... the type seems to be precisely what I'm looking for ... I am not yet sure if the onus of freeing can be offloaded to the client, but it definitely seems promising
<blinghound> happy to help!
<antaoiseach> On second thoughts, I think I can live with that... so that's that. Cheers! :-)
<blinghound> good luck!
<antaoiseach> Thank you! Hasta la fuego! :-)
antaoiseach has quit [Quit: leaving]
<alexnask> blinghound, I misundersttod what you wanted to do, I think just making the quad id a regular field here would work
<alexnask> The instances will still be comptime
<alexnask> Let me clean it up a bit and sending you the modified link
<blinghound> oh awesome, but the structs do count the field in their size right?
<blinghound> because if possible I'm trying to avoid it
<alexnask> Yeah. Basically you cant mix comptime and runtime mutable state in a single type rn
<blinghound> ahh ok I understand
<alexnask> The "comptime closure" I am talking about is a trick to return a unique type every time
<alexnask> And use a comptime var for each type
<alexnask> So it wouldnt work in something like this though it can be useful for other stuff
<blinghound> does that method use a generic type function with a comptime variable?
<blinghound> could I move the comptime struct members somewhere else that the structs can refer to?
<blinghound> to avoid actually storing those quad_id fields during runtime
<alexnask> This is the cleaned up version: https://godbolt.org/z/tcfW3e
<alexnask> Let me find some example with a comptime closure Ive written a couple
<blinghound> I appreciate the help :)
<alexnask> Here is a type that does it: https://zig.godbolt.org/z/ZSY8Vx
<alexnask> The crucial part is the following: ErrorDispatcher accepts a var argument
<alexnask> By passing .{} you can force it to be re evaluated (since all comptime calls are cached) because its type is unique at every call site
<alexnask> So every ErrorDispatcher(.{}) will have a single `comptime var curr_set: type = void;`
<blinghound> ohh I see
<alexnask> As I noted though this means the type returned is different every time
<alexnask> So you cant make an array of them
<alexnask> People have used this trick to great effect
<alexnask> E.g. this type which I think could be useful or even working borrow checking (https://github.com/DutchGhost/zorrow/)
<alexnask> What you want is probably more similar to https://github.com/ziglang/zig/issues/5675 though
<blinghound> yeah I think that's exactly what I want
<blinghound> I assume I can't do something crazy like make the Shape union, Rectangle and Circle all generic types with comptime quad_id parameters?
<alexnask> you could probably achieve this by holding two separate lists
<alexnask> one comptime list with the quad ids and one runtime list of the shapes
<blinghound> that's a good idea!
<alexnask> Although here quad_id == index in the list so it isnt even needed but I assume you want to do something more complex down the line :)
<blinghound> unless I could make the quad_id field just a pub var quad_id initialized at comptime?
<blinghound> just to avoid having it in the struct
<alexnask> It will not be unique per instance though which is what you seem to want
alexnask has quit [Quit: Leaving]
<blinghound> as a pub var I do get 'error: unable to evaluate constant expression'
<blinghound> yep, I think I'll use your list idea
alexnask has joined #zig
aerona has joined #zig
_Vi has joined #zig
<Aransentin> Is it safe to `allocator.free()` an `&[0]u8{}`, analogous to `free(NULL);` in C?
<Aransentin> ... well, the code in `mem.zig` appears to support it. In absence of a contract I suppose that'll do.
blinghound has quit [Remote host closed the connection]
layneson has joined #zig
layneson has quit [Ping timeout: 260 seconds]
Akuli has joined #zig
traviss has quit [Quit: Leaving]
layneson has joined #zig
dermetfan has quit [Ping timeout: 240 seconds]
doublex has quit [Ping timeout: 240 seconds]
layneson has quit [Ping timeout: 264 seconds]
layneson has joined #zig
<pixelherodev> Aransentin: that wouldn't be akin to a free(NULL) at all
<pixelherodev> That would be more like `int i = 0;free(&i)`
<pixelherodev> Pointers to temporaries in Zig are defined within scope
<Aransentin> the ampersand is just to make it into a slice
<alexnask> Aransentin, I think this is correct, cant find any contract in the doc comments either but Im pretty confident empty slices are just ignored when shrinking
<alexnask> Someone correct me if im wrong
* pixelherodev facepalms
<pixelherodev> Oh right
<pixelherodev> Taking the address of a zero-sized value gives NULL? Then yeah, I think that's okay currently
<pixelherodev> With page_allocator, worst case, it'd give NULL to munmap
<pixelherodev> Which, according to the man page, should be perfectly fine
<pixelherodev> andrewrk: how goes the test? :)
wootehfoot has joined #zig
<alexnask> pixelherodev, Idk, is there a test that does this directly with the page allocator? Prob not
dddddd_ has joined #zig
<pixelherodev> ah gotcha
<pixelherodev> I would've expected child process to fail too
<pixelherodev> unless it's not tested?
dddddd__ has joined #zig
dddddd has quit [Ping timeout: 264 seconds]
<alexnask> Not sure
dddddd_ has quit [Ping timeout: 260 seconds]
<alexnask> It will only fail with the `exec` function though (the one liner interface)
<alexnask> Because it readAllAlloc's
layneson has quit [Ping timeout: 265 seconds]
dddddd__ is now known as dddddd
doublex has joined #zig
layneson has joined #zig
dddddd_ has joined #zig
dddddd has quit [Ping timeout: 260 seconds]
layneson has quit [Ping timeout: 256 seconds]
doublex has quit [Ping timeout: 260 seconds]
<pixelherodev> Testing, hi
<pixelherodev> Okay, probably good
doublex has joined #zig
<pixelherodev> (don't ask :P)
cole-h has joined #zig
_Vi has quit [Ping timeout: 244 seconds]
<mq32> pixelherodev: what are you doing? :D
<andrewrk> I wonder if there is any performance to be exploited from a hash map implementation where it's assumed that the only operations are insert and read (no deletion support)
<pixelherodev> Until deinit, I assume?
<pixelherodev> Hmm, that's an interesting idea
<pixelherodev> mq32: disabled WLAN, switched to Ethernet on buildbuddy (which is also what I run tmux + weechat on ;)
<pixelherodev> Ethernet was failing to DHCP for a while, but it's good now
<pixelherodev> As long as I don't restart the computer again lol
<pixelherodev> Router is dumb
waleee-cl has quit [Quit: Connection closed for inactivity]
penguinicus has quit [Ping timeout: 245 seconds]
<Akuli> andrewrk, python's new (3.6) ordered dict implementation is efficient for that kind of use
<Akuli> it's an array of data and then a tiny hash table of indexes into that array
<Akuli> i'm not sure how they got deletion to work sanely, but i think that's pretty much what you're looking for, hash table that behaves the best if you don't delete
cole-h has quit [Quit: Goodbye]
<shakesoda> are there any examples of dealing with std.childprocess
<andrewrk> shakesoda, yes, search the test directory=
<andrewrk> Akuli, interesting!
<shakesoda> andrewrk: ok, thanks
<Akuli> andrewrk, raymond hettinger has a nice pycon talk about this on youtube
<Akuli> essentially going through all the design choices quickly
<Akuli> the result is that they have a hash table that is faster and takes up less space than their older hash tables, but still remembers insertion order
<Akuli> (you need to s/dict/hashtable/ mentally if you're not a python user)
dddddd__ has joined #zig
layneson has joined #zig
<andrewrk> bookmarked
dddddd_ has quit [Ping timeout: 246 seconds]
_Vi has joined #zig
<pixelherodev> Zig has ruined other languages for me
<pixelherodev> `go run` -> invalid `or`
<pixelherodev> :P
dddddd_ has joined #zig
<shakesoda> pixelherodev: seems right
<shakesoda> as an added bonus, pretty much everything i still want is on the todo list
<pixelherodev> ?
<pixelherodev> What TODO list?
<shakesoda> issues/accepted stuff
<marler8997> alexnask, did you end up finding an issue with the new allocator interface?
<shakesoda> by that i also mean things that are in progress
<alexnask> marler8997, I think its the page allocator implementation, not the interface itself
<shakesoda> namely: faster builds, concurrent builds, 1717 etc
<alexnask> Didnt dig too deep imo
dddddd__ has quit [Ping timeout: 260 seconds]
<pixelherodev> Gotcha
dddddd has joined #zig
<shakesoda> zls fills the biggest complaint i've had for really using zig other than the build performance
<shakesoda> really, really helpful
<marler8997> alexnask, I'll look into it
<marler8997> might as well take advantage of having everything fresh while I can
<shakesoda> s/fills/resolves/
<shakesoda> there are of course a few run of the mill bugs too, but of course there are some of those.
<shakesoda> i can't think of any currently affecting me that aren't related to c interop though
dddddd__ has joined #zig
dddddd_ has quit [Ping timeout: 265 seconds]
dddddd has quit [Ping timeout: 264 seconds]
<pixelherodev> packed structs
<pixelherodev> Those are the last major one :P
<shakesoda> in general, or with interop
<pixelherodev> In general
<pixelherodev> Well
<pixelherodev> Freestanding, really
<pixelherodev> Anything that needs precision
waleee-cl has joined #zig
<marler8997> alexnask, it's a mistaken memset, I added a memset to memory that had been freed by the pageallocator, after it had been freed
<alexnask> Yeah I was asssuming it was writting in the freed page
<alexnask> But wasnt sure
<marler8997> this is why memset needs to be done in the allocator (andrewrk told me about this already)
FireFox317 has joined #zig
<marler8997> alexnask, fix here: https://github.com/ziglang/zig/pull/5744
<FireFox317> andrewrk, IIRC there is a vim plugin for vscode, that mimics vim behavior in vscode. Maybe you will like it :P
<alexnask> marler8997, Cool tyty
Yardanico has quit [Ping timeout: 272 seconds]
Yardanico has joined #zig
<Aransentin> My windowing library now creates a win32 "hello world" window on Windows as well, in addition to X11: https://github.com/Aransentin/ZWL
<Aransentin> It'd be kinda cool if I could use ntdll exclusively (i.e. nothing from user32), but I'm not sure that's practically possible.
ur5us has joined #zig
<pixelherodev> missing errdefer in go :P
<ifreund> errdefer is the shit
<ifreund> though I really wish it worked in blocks
<pixelherodev> It... does
<pixelherodev> Ah wait
<pixelherodev> I see what you mean
<pixelherodev> You mean to avoid returning the error fully?
<squeek502> @Aransentin, cool, this fork of zig-window seems to be going for something very similar: https://github.com/Luukdegram/zig-window
Akuli has quit [Quit: Leaving]
<Aransentin> Ah, interesting. I'll have to check that out...
<alexnask> Oh shit someone noticed us
<alexnask> *ducks*
<Aransentin> Huh, really interesting reading other peoples code when you've been working on the exact same same thing for a while :)
<alexnask> Keep in mind I hacked this pretty quickly
<alexnask> :p
<alexnask> Dont shoot me D:
FireFox317 has quit [Remote host closed the connection]
<Aransentin> You're gonna support remote X11? I was kinda dropping that... There's no analogue on the other platforms, and you have to write a lot of stuff twice since remote X11 only supports the ancient super-slow path.
<ifreund> second that ^
<alexnask> Im not really familiar with the x11 stuff andrew and luuk wrote them
<alexnask> *shrugs*
<ifreund> waypipe is the future :P
<Aransentin> hehe :)
stripedpajamas has joined #zig
ifreund has quit [Ping timeout: 265 seconds]
<pixelherodev> Wayland = <3
<Aransentin> I figured out that you can cut down a whole lot of X11 code if you just assume that the server you're talking to was compiled sometime after 1990... Like, I'm not even checking that it supports RGB color.
ifreund has joined #zig
<wilsonk> hey alexnask, do you know if the newest ZLS from a couple minutes builds with zig master from a couple minutes ago? I am getting an error at semantic_tokens.zig:205 expected 4 arguments found 1
<alexnask> Let me check, I fixed the build this morning
<wilsonk> coolio
<alexnask> The call does have 4 arguments in zls master at that line tho :P
<wilsonk> hmm, deleted cache and rebuilt but got the same problem
<wilsonk> let me try the same with zig
<alexnask> Im building zig master rn, Ill let you know in 5 mins
<wilsonk> weird, cleared cache and rebuilt zig and now I get 'zig/build/lib/zig/std/dwarf.zig:362:26: error: expected 4 arguments, found 8' when building ZLS ... wth
traviss has joined #zig
<alexnask> Did you `make install`?
<wilsonk> oh, what the crap!! I just rebuilt both zig and zls and now it worked?? I must have tried to rebuild zls while zig was still only partially installed, I guess
<alexnask> :D
<ifreund> i need to update zls again after I finish implementing fullscreen
<wilsonk> yeah, I did but as I was typing above...I must have not waited for the full install before trying to build zls (I do these things on different screens and probably jumped the gun ;) )
<ifreund> saw that sweet semantic highlighting improvment :)
<wilsonk> sorry for the noise
stripedpajamas has quit [Quit: sleeping...]
<Aransentin> Hm, I kinda want X11-over-the-network anyway, for two reasons: It enabled you to debug the protocol easily with Wireshark, and you can now run programs in wine that talks to your regular X11 server which is kinda dope for demo purposes...
st4ll1 has joined #zig
blinghound has joined #zig
<blinghound> hmm I'm getting a strange segfault
<blinghound> pub fn onLeftMouseDown(self: *SearchBar, ui: *UserInterface) void { self.is_focused = true; }
<blinghound> segfaulting on the self.is_focused = true;
<mq32> that sounds like you're passing a invalid pointer there
<blinghound> switch (self.*) { ... other widgets ... .SearchBar => |*s| s.onLeftMouseDown(ui), else => unreachable, }
<blinghound> sorry, formatting
<blinghound> the only thing is, it's being called successfully here, and I can print the address and values of the SearchBar that's being called
<ifreund> a pastebin would be preferable for stuff that's more than one line
<ifreund> blinghound: why self.* in the switch?
<ifreund> er, maybe I'm thinking about this wrong, might need to see more code
<blinghound> it's a self.* because I'm passing the instance by reference
nikita` has quit [Quit: leaving]
<blinghound> and then checking the union type (SearchBar etc)
<blinghound> Widget is a union
<andrewrk> blinghound, have you tried running it in valgrind?
<ifreund> huh, well I don't see anything amiss in that snippet
<ifreund> valgrind +1
<blinghound> I'll be honest, I don't have much experience with valgrind
<ifreund> it's pretty straightforward to use tbh
<blinghound> I've only used gdb for c/c++ debugging
<ifreund> you just run valgrind ./myprogram
<pixelherodev> Or
<ifreund> and it spits out useful info
<pixelherodev> `valgrind -s --leak-check=full ./myprogram`
<ifreund> yes you can pass flags to get more detailed output
<blinghound> I'll give it a shot
<ifreund> (you do need to be using the c allocator for it to work fyi)
<blinghound> yup I'm using the c allocator
<blinghound> ah crap, I'm on windows though
<andrewrk> maybe it would work in the WSL?
<blinghound> I'll give it a whirl in WSL
<andrewrk> also, I know this doesn't help you know, but there are compiler features planned that would catch this sort of thing. not 100% but with a high chance
<gonz_> blinghound: How is the payload of `SearchBar` being set?
<blinghound> all the values are as they should be if I print them, and I set all widgets at startup
<blinghound> it's passed by pointer and I can print out it's own values in the same function
<blinghound> but it segfaults when I try to modify bool field on itself
layneson has quit [Ping timeout: 240 seconds]
<blinghound> andrewrk can't wait ;D I'm going to have to recompile all the c libraries I'm using on my linux box before I can use valgrind it seems
<andrewrk> it'll probably worth it. valgrind is incredibly useful
<gonz_> blinghound: What does the Widget union look like?
<blinghound> gonz_ like this https://pastebin.com/SRGgzwyL
<blinghound> I removed all but two of the widget types while I was testing, so I left it as that when pasting
<blinghound> all of the functions work as intended, apart from setting a struct member from within their own functions
dermetfan has joined #zig
<blinghound> are there any obvious issues with the way I set up the widget tagged union?
<gonz_> No
<andrewrk> in the drop down on top of ArenaAllocator, you can change it between std_gpa (std.heap.page_allocator) and libc (std.heap.c_allocator)
<ifreund> nope, but if you don't mind unsolicited style tips I'd do https://paste.rs/5Uv
<andrewrk> marler8997, it looks like the changes to ArenaAllocator are a pretty significant perf regression
<andrewrk> e120b07a524 I mean
<gonz_> blinghound: Yeah, I can't see from what you've pasted what could be the issue.
<blinghound> ifreund I didn't know if union field names should be capitalized or not ;)
<blinghound> gonz_ yee I'm stumped
<ifreund> enums shouldn't either anymore fyi
<ifreund> I'd try to refactor things, there's always a chance that this could be a stage1 compiler bug
<ifreund> i assume valgrind doesn't really work on windows/
<blinghound> I couldn't get it to work with WSL nope
<blinghound> I'll try on my linux machine tomorrow
<blinghound> I did wonder if it was a stage1 bug, but 90% of the time it's usually my own fault
<blinghound> 90% and usually don't work together there
<blinghound> I'm tired :D
<ifreund> valgrind also might just point right at where the issue is tomorrow with a little luck
_Vi has quit [Ping timeout: 272 seconds]
<andrewrk> damn how is it 4pm already? all I've done today is eat breakfast and sit on the couch figuring out how register allocation is going to work
<blinghound> it's 00:11 here and I can't rest until I fix this bug
<andrewrk> there's also this tool: https://rr-project.org/
<andrewrk> also linux-only...
<ifreund> I agree, time moves too fast
<ifreund> 01:11 here
<blinghound> andrewrk DAYUM that's nice, I'm definitely trying that tomorrow
<blinghound> are you in Germany ifreund?
<ifreund> indeed
<ifreund> though I'm actually an american
<blinghound> you pulled a fast one on us there
<blinghound> I'm in the UK and half american
<gonz_> ifreund: Does your last name work out well for you in Germany? :D
<ifreund> it's a fun last name for sure :D
<blinghound> ok I'm able to print the address of the field one line before trying to modify it, and I get that error
<pixelherodev> You say linux-only like that's a bad thing
<gonz_> pixelherodev: How would it be an upside?
<gonz_> Unless you mean for the developer.
<gonz_> And in this case he's saying that because blinghound is working on Windows atm, trying to debug this thing.
<pixelherodev> andrewrk: register allocation is a concern?
<pixelherodev> I can work on that! :)
<blinghound> yeah he's trying to kick me while I'm down
<blinghound> ;)
<pixelherodev> Did you get basics of paramters working?
<pixelherodev> parameter lookups*
<andrewrk> pixelherodev, there is plenty to do that isn't literally exactly the same thing I am in the middle of implementing
<blinghound> not sure if I'm reading the error wrong andrewrk, but could it be a windows issue?
<pixelherodev> I know :P
<pixelherodev> I'm really tempted to write an additional register allocator though
<pixelherodev> Run some numbers, see how they compare
<pixelherodev> :P
<gonz_> blinghound: How does the definition of SearchBar (the payload) look?
<gonz_> packed!
<blinghound> like this, I've tried non-packed and packed
<gonz_> I knew it
<gonz_> Oh, and you get this with both?
<blinghound> I thought I was because of that too :(
<gonz_> That makes it even more curious
<pixelherodev> andrewrk: jokes aside, what *would* be useful for me to focus on right now?
<pixelherodev> Aside from graph script :P
<gonz_> I don't use it at all in any context now because I'm gun-shy. The last BS error & segfault I had was related to this and I hadn't read up on the issue tracker about it yet.
<andrewrk> blinghound, the error is a segfault in the application. the integer overflow is a problem with the stack trace printing code itself
<gonz_> Once no one even remembers when `packed` was broken I'll start using it.
<blinghound> thanks for taking a look andrewrk, I'll give valgrind a go tomorrow!
<andrewrk> blinghound, you gotta figure out why writing the is_focused field of `self` in this case is a use-after-free
<andrewrk> pixelherodev, how about cpu feature detection for more architectures? or getting the hello world example passing on more architectures?
<pixelherodev> Righty!
<pixelherodev> Oh right
<pixelherodev> andrewrk: any objections to adding some custom ISAs soonish? :)
<andrewrk> none
<pixelherodev> Brilliant
<andrewrk> might be helpful to start with a non-exotic one first tho
<pixelherodev> Going to work on self-hosted feature detection for a while thing :P
<pixelherodev> It's very non exotic
<pixelherodev> That's one reason I want to test it :P
<pixelherodev> It's one of the ISAs I JITed
<blinghound> holy crap I fixed it! I was creating the array of widgets at comptime, and assigning it to a runtime array somewhere else, and because every other function worked, I just assumed the fields could be modified
<gonz_> Ohhh
<blinghound> I was reading some of the struct fields at runtime and it worked..
<gonz_> blinghound: Good find, happy that you didn't have to leave it unsolved :)
<blinghound> me too! The feeling of relief after solving an issue like this, jesus
<andrewrk> blinghound, oh, there's an open issue to make this a compile error btw, sorry about that
<andrewrk> you should have got something like "expected *Foo, found *const Foo"
<pixelherodev> CPU detection for ARM is probably a good place to start, since I meant to do that a long time ago
<blinghound> ohh ok, I'm glad the issue has already been found though andrewrk
<blinghound> night guys! I can finally rest peacefully
<blinghound> thanks for all the help
blinghound has quit [Remote host closed the connection]
<andrewrk> night
<gonz_> GN :)
ofelas has quit [Ping timeout: 240 seconds]
<gonz_> Does anyone know what executable format OpenSolaris & derivatives (Illumos, etc.) use?
<gonz_> You can use ELF, but is that the standard?
<pixelherodev> If you can use ELF, I'd suggest doing so
<ifreund> got fullscreen implemented and it seems to work well
<ifreund> time to go to sleep
dermetfan has quit [Ping timeout: 272 seconds]
layneson has joined #zig
<gonz_> GN. I'm going too, I guess, approaching 03:00 here.