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/
ur5us has joined #zig
alichay has quit [Remote host closed the connection]
protty has quit [Quit: Ping timeout (120 seconds)]
blackbeard420 has quit [Quit: ZNC 1.7.5 - https://znc.in]
blackbeard420 has joined #zig
nore has quit [Ping timeout: 240 seconds]
ave_ has quit [Quit: Connection closed for inactivity]
scientes has quit [Ping timeout: 240 seconds]
nore has joined #zig
redj has joined #zig
<daurnimator> mq32: add completion support to your arg parser :)
<daurnimator> mq32: i.e. have a method "pub fn writeCompletions(enum {bash, fish, zsh}, myoutstream) !void`
a_chou has joined #zig
a_chou has quit [Client Quit]
protty has joined #zig
<protty> andrewrk: Realized the issue: the node's `prev` wasn't being reset after being notified so the queue ended up in an error state.
lunamn_ has quit [Quit: leaving]
lunamn has quit [Quit: leaving]
mahmudov has quit [Remote host closed the connection]
protty has quit [Remote host closed the connection]
alexnask has quit [Ping timeout: 268 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzzโ€ฆ]
alexnask has joined #zig
alexnask has quit [Read error: Connection reset by peer]
alichay has joined #zig
nikoala has quit [Ping timeout: 265 seconds]
vegecode has joined #zig
<vegecode> Can anyone tell me what the recommended way to do type punning is? I'm looking for something equivalent to teh following:
<vegecode> typedef union
<vegecode> crap how do i do small code snippets
<vegecode> I'm trying to do the equivalent of a union in c where one union member is a struct of bitfields like for flags and then the other member is an integer that is the width of all teh flags combined
<vegecode> Common C idiom for representing lfags
<vegecode> I think I can make it be a union and then just change the active member by doing a write to the other member with undefined. Is there a better way? Do I just have to shift and mask everything?
<vegecode> maybe bit casting between a packed struct and the full width type?
<fengb> packed struct for the bits. Depending on how often you use the full type, a packed union or bitcasting
<mikdusan> but zig union is one-field active at a time rather than a "bitcast" exchange hub :)
<fengb> Not packed union
<vegecode> does a packed union skip the safety check of which field is active then?
<mikdusan> fengb: ah nice
<fengb> Yes
<vegecode> skip it intentionally I mean
<vegecode> thank you sir!
<vegecode> One more thing, before I pollute the issue tracker, is it reasonable to request some movement on a proposal? Either accpet or reject. Specifically #4284
<mikdusan> lookin at #4284 I think you already have an answer: on Jan 25 it was added to 0.7.0 milestone
<vegecode> That was the day it was opened and the "accepted" label was never added
<vegecode> I sure hope it's not accepted. I'm quite opposed.
<andrewrk> Milestones on non accepted proposals mean it's not planned to make a decision until that release cycle
<vegecode> perfect, thanks
ur5us has quit [Ping timeout: 240 seconds]
ur5us has joined #zig
<daurnimator> andrewrk: can has merges? :)
<fengb> `self.code % 16 + '0'` lol whoops I fail at hexamath
<mikdusan> so 0xffff = 0x???? and 0xaaaa = 0x:::: ... I'm ok with that
waleee-cl has quit [Quit: Connection closed for inactivity]
<fengb> `i32.const 420` => `.I32 = -15964`
<fengb> I don't think this is working quite right
ur5us has quit [Ping timeout: 240 seconds]
<fengb> `else if (0x40 != 0` I think I forgot a variable
<fengb> I am so smrt
<BaroqueLarouche> now I imagine fengb's house in fire
<daurnimator> forgetting a variable: not even once.
<fengb> Well, I'm glad I didn't build my own house
dddddd has quit [Remote host closed the connection]
vegecode has quit [Remote host closed the connection]
slowtyper has joined #zig
slowtyper has quit [Quit: WeeChat 2.7.1]
rom1504 has quit [*.net *.split]
gchristensen has quit [*.net *.split]
M-ou-se has quit [*.net *.split]
mht has quit [*.net *.split]
shachaf has quit [*.net *.split]
xvilka has quit [*.net *.split]
pmwhite has quit [*.net *.split]
AlexMax has quit [*.net *.split]
dtz has quit [*.net *.split]
jicksaw has quit [*.net *.split]
halbeno has quit [*.net *.split]
s-ol has quit [*.net *.split]
Cloudef has quit [*.net *.split]
euantor has quit [*.net *.split]
wjlroe has quit [*.net *.split]
shodan45 has quit [*.net *.split]
Prf_Jakob has quit [*.net *.split]
jrl has quit [*.net *.split]
diginet has quit [*.net *.split]
cow-orker has quit [*.net *.split]
commander has quit [*.net *.split]
nickster has quit [*.net *.split]
andrewrk has quit [*.net *.split]
wtw has quit [*.net *.split]
notjones has quit [*.net *.split]
Sahnvour has quit [*.net *.split]
benaiah has quit [*.net *.split]
johnLate has quit [*.net *.split]
Ekho has quit [*.net *.split]
idxu has quit [*.net *.split]
hspak has quit [*.net *.split]
niftynei has quit [*.net *.split]
lukeholder has quit [*.net *.split]
edr has quit [*.net *.split]
dom96 has quit [*.net *.split]
cota has quit [*.net *.split]
fengb has quit [*.net *.split]
ianc6209 has quit [*.net *.split]
companion_cube has quit [*.net *.split]
guan has quit [*.net *.split]
grayhatter has quit [*.net *.split]
_whitelogger has joined #zig
return0e has joined #zig
CommunistWolf has joined #zig
blackbeard420 has joined #zig
doublex_ has joined #zig
BaroqueLarouche has joined #zig
lqd has joined #zig
Snektron has joined #zig
tralamazza has joined #zig
APic has joined #zig
jmiven has joined #zig
Cadey has joined #zig
mixi has joined #zig
torque has joined #zig
mforney has joined #zig
APic has quit [Max SendQ exceeded]
APic has joined #zig
alexnask has joined #zig
alichay has quit [Quit: Konversation terminated!]
marmotini_ has joined #zig
marmotini_ has quit [Ping timeout: 255 seconds]
<alexnask> andrewrk, Is it expected behavior that the calling convention and type of inferred async functions is .Unspecified and non-async fn ptr?
<mq32> <daurnimator> mq32: add completion support to your arg parser :)
<mq32> never used something like that, can you elaborate?
<daurnimator> mq32: do you have luarocks installed?
<mq32> maybe? D
<mq32> nope
<daurnimator> mq32: kubectl?
<mq32> negative
<daurnimator> uh... okay. so many commands have the ability to output bash/fish/ksh completions for themselves
<daurnimator> which you tell your shell about, so you can type (e.g.): luarocks in<TAB> and it completes to `install`
<mq32> hm, sounds useful
<daurnimator> ==> same for all arguments of the program `luarocks --c<TAB>` => `luarocks --config`
<daurnimator> depending on your shell configuration, people even set it up to have pretty menus and things
<mq32> can you point me to some docs for this?
* mq32 uses only bare-bones completion of bash
<daurnimator> mq32: I can help most with luarocks's version of it.... cause adding that was the GSoC project I mentored last year :)
<daurnimator> mq32: what distro are you on?
<mq32> arch linux
<daurnimator> mq32: excellent; `pacman -S luarocks` ?
hazeycode has joined #zig
<mq32> "yay luarocks"
<daurnimator> mq32: okay, and now have a quick peek: `cat /usr/share/bash-completion/completions/luarocks`
<daurnimator> (you should see: `source <(luarocks completion bash)`)
<mq32> yep
<daurnimator> not sure if you need to start a new shell first, but try typing: `luarocks ins<TAB>` => it should complete to `luarocks install`.
<mq32> nope, nothing happens
<daurnimator> mq32: okay, just open a new terminal window
<mq32> did already
<mq32> ack
<daurnimator> mq32: you said you use bash right...
<mq32> i assume i have to manually add the completion-script?
<daurnimator> nope. should get picked up automatically
_Vi has quit [Ping timeout: 272 seconds]
<daurnimator> mq32: and `luarocks install --<TAB><TAB>` should give you a list of options available
<mq32> yep
<daurnimator> mq32: okay, so that's what many end users want :)
<daurnimator> mq32: now, to delve into how its done: have a look at the output of `luarocks completion bash` => its a large string/bash script
<mq32> yep, already doing this
<daurnimator> mq32: that string/bash script is generated by the argument parser inside of luarocks
<alexnask> stupid question: are fish completions compatible or does the arg parser need to generate a competion file for each shell it supports?
<mq32> looking at "luarocks completion bash" it seems like fish needs a different file :D
<daurnimator> mq32: and zsh needs its own too
<daurnimator> alexnask: they each need their own format
<daurnimator> hence why the `completion` subcommand takes an argument of the shell...
<daurnimator> for zsh you'll see /usr/share/zsh/site-functions/_luarocks and for fish you'll see /usr/share/fish/vendor_completions.d/luarocks.fish
<alexnask> Search Results
<alexnask> Web result with site links
<alexnask> ๐Ÿ‘
<alexnask> woops
hazeycode has quit [Ping timeout: 260 seconds]
marmotini_ has joined #zig
marmotini_ has quit [Remote host closed the connection]
marmotini_ has joined #zig
marmotini_ has quit [Ping timeout: 260 seconds]
dddddd has joined #zig
_Vi has joined #zig
TheLemonMan has joined #zig
dimenus has joined #zig
metaleap has joined #zig
<dimenus> andrewrk: when trying to link libc on manjaro (glibc 2.31), i'm getting missing 'misc/bits/syscall.h' header
<andrewrk> dimenus, hmm ok I'm investigating
<andrewrk> dimenus, can I see the full error output?
<andrewrk> also can you confirm this is after 3ff2381042 (yesterday)?
<dimenus> it is, i'll get you a trace
<andrewrk> I'm confused why I can't reproduce it
<andrewrk> I don't know what would be different about building it on my system vs yours
waleee-cl has joined #zig
<dimenus> hmmm, deleting my previous build and wiping out ~/.cache/zig fixed it
<andrewrk> what do you mean by deleting your previous build?
<dimenus> i fully deleted my build folder (i'm not doing a system wide install)
<dimenus> it's quite possible, in my wayland example i'm only linking libc and i got that error
<andrewrk> I bet it is 2044
<dimenus> you're so quick with the issues btw :)
<andrewrk> it helps when you have them all memorized
<andrewrk> zig is small enough that it fits in my head
<dimenus> but yeah, clean build and it works as expected
<andrewrk> glibc goes nuts with same-named .h files and relying on include order
<andrewrk> I was looking at porting cache_hash.cpp into zig last night (coincidentally with LeRoyce's PR) and I believe it can be done in O(1) memory, allocator needed
<dimenus> nice
<fengb> Debugging raw bytecode is so miserable
<andrewrk> work on features to make debugging raw bytecode not miserable
<fengb> Yeah soonโ„ข
<andrewrk> it will pay off big time
<fengb> Gonna need to revive my sexpr parser so I don't have to write bytecode all the time
<alexnask> @andrewrk, Would you be ok with a SCOPE_DEFER {...} macro (that creates an object that runs a lambda on destruction) in utils.hpp?
<alexnask> I want to start freeing a bunch of temporaries
<andrewrk> alexnask, nah no macros
<alexnask> Ok
<andrewrk> sorry
<andrewrk> I've been thinking, a long term stretch goal of stage1, once we are shipping self-hosted, would be to reduce it to C (not C++) and have it generate C code rather than using llvm
<andrewrk> then we would be able to bootstrap the (vaporware) self-hosted non-llvm-backend compiler from only a C compiler
dimenus has quit [Remote host closed the connection]
<andrewrk> which is not a pointless endeavor - it would make zig viable to use as a compiler in a fledgling OS or new CPU architecture
<alexnask> Right (I suppose it would generate C89 too then :P)
<alexnask> For maximum portability
<andrewrk> yeah, you get the idea
<metaleap> from the outside, i'm curious about your eagerness to be potentially/partially/incrementally llvm-independent. does ll not live up to the hype, does it incur friction? too buggy? or is it just general desire for fewer dependencies in-the-very-long-run-future?
<mikdusan> instead of [stage1 -> C -> stage2] why not [stage2 -> C -> stage2]
<companion_cube> a language striving to be simple and standard shouldn't depend on a beast like llvm (or rather it shouldn't be a single point of failure?)
<mikdusan> as in stage2 generates C code
<andrewrk> mikdusan, because the generated C isn't "source" code and cannot be audited as such
<andrewrk> it's tempting though. idea would be to do it once, and then sort of "de-obfuscate" it and "sourceify" it
<andrewrk> sort of what go did when they translated from C, except in reverse
<fengb> LLVM is an implementation detail, not a spec. We use it for a bunch of really nice features, but it's also has its own quirks and challenges
<andrewrk> mikdusan, also we'd need to build N versions (one for each target) and then merge them with #ifdefs
<companion_cube> fengb: well it's kind of influencing the specs of what's an intrinsic, isn't it?
<fengb> In the near-term, we'd like faster debug builds, which LLVM is somewhat of a bottleneck. Odin and Jai have the same issues
<companion_cube> with a C backend, how do you provide portable simd? :/
<andrewrk> companion_cube, same way you emit portable simd when the target cpu does not have simd features
<companion_cube> by emulating them? fair enough :)
<fengb> companion_cube: sort of. Intrinsics are what I'd consider "some CPUs have instructions, but we can provide a userland implementation if necessary"
<companion_cube> ok, I guess that's fair
<companion_cube> as long as the semantics is the same
<companion_cube> (same as `popcount` and the likes, actually)
<mikdusan> if we [stage2->C] to bootstrap onto a platform, that is done just once, and the codegen benefits from all zig userland smarts to see what the target is, etc. and one'offs some C. then we build a (stage2)0 with target host buildtools. and bob's your uncle.
<fengb> mikdusan: are you british?
<mikdusan> fengb: nah I just like that phrase
<andrewrk> metaleap, a lot of the communities that zig wants to reach (people who are currently using C) feel that LLVM is too much of a monoculture
<andrewrk> ...which is true. we need a language spec that is independent of LLVM. and a non-llvm-backend is proof that it is viable
<metaleap> ah well what i heard in terms of criticism so far is that its a c-focused monoculture :D
<companion_cube> also, yeah, but that matters more if you either want to use optimizations that are infeasible in C, or if you want GC support :)
<metaleap> not a bad aspiration for sure, was just curious if there were "burning" reasons or merely "lets become proper-er over time" reasoning
<fengb> Does Rust have a non-LLVM compiler?
<companion_cube> nope
* BaroqueLarouche hopes to find/have time to write non-llvm backend for retro consoles when self-hosted compiler is shippable
<companion_cube> and it's imho a shortcoming of rust
<TheLemonMan> they're working on a cranelift-based backend
<fengb> metaleap: the goal was always there. LLVM merely enables us to ship "production-grade" code earlier
<companion_cube> what I'm wondering is, wouldn't a wasm (direct) backend be a viable first-class backend?
<andrewrk> mikdusan, I think that's something worth considering once we are shipping self-hosted and have a C backend
<companion_cube> no one said languages should only target native architectures
<fengb> We've also inherited some LLVM baggage... like old coroutines...
<andrewrk> the goal of bootstrapping is to get from hand-typing hex code directly into an executable file, to a fully featured self-hosted compiler
<andrewrk> wasm introduces unnecessary steps in that sequence
<fengb> what about CPUs that natively execute wasm? ๐Ÿ™ƒ
<fengb> Oh speaking of which, I managed to get my wasm vm execute 1 function with 1 instruction! No longer complete vaporware
<andrewrk> nice work
marmotini_ has joined #zig
<fengb> https://github.com/ziglang/zig/issues/4631#issuecomment-595337885 another win for Zig over LLVM right? :P
<TheLemonMan> how is that a win?
<TheLemonMan> andrewrk, is ir_get_ref supposed to work on runtime-known values?
<andrewrk> TheLemonMan, yes, it creates a stack allocation
<TheLemonMan> it seems to badly choke on such a value when it tries to call ir_llvm_value during the codegen phase
<andrewrk> choking on ir_llvm_value can happen if the instruction incorrectly did not get generated previously
return0e has quit [Ping timeout: 255 seconds]
frett27 has joined #zig
<TheLemonMan> oh, let me see if that's the problem
marmotini_ has quit [Remote host closed the connection]
frett27 has quit [Ping timeout: 240 seconds]
<andrewrk> flexing a little bit on the llvm-dev mailing list: http://lists.llvm.org/pipermail/llvm-dev/2020-March/139772.html
<andrewrk> much of that is TheLemonMan's work
<andrewrk> it took 9.5 hours to run the full zig test suite with debug build of llvm
<mikdusan> passed?
<andrewrk> yes
<mikdusan> you need more ghz
<andrewrk> need more utilizing cpu cores :)
<fengb> How important is Zig to LLVM? :P
<mikdusan> andrewrk: what does your gut say the main focus for 0.6.0 -> 0.7.0 will be?
<andrewrk> stabilizing the language, specification, and self-hosted compiler
<TheLemonMan> andrewrk, the source instruction looks fine https://clbin.com/AfBBi , I don't remember if the GenConst with (runtime value) is ok at IR level
<andrewrk> I think a GenConst with runtime value is suspect
o_O has joined #zig
<andrewrk> TheLemonMan, btw did I ever show you how to use the IR debugging features? size_t break_debug_id; // for debugging purposes
o_O is now known as Guest20151
<TheLemonMan> yeah, I noticed those a while ago
metaleap has quit [Ping timeout: 260 seconds]
<andrewrk> damn, 0.5.0 release notes says "it's time to begin on networking in the Standard Library. I expect to complete this along with at least an early prototype of the package manager during the next release cycle."
<fengb> You have a month to catch up :P
<andrewrk> we've completed so many things this cycle, and yet reading this old roadmap makes me feel like no progress has been made
<TheLemonMan> alexnask, awesome work on #4643!
<alexnask> Thanks
<alexnask> Tackling #3237 now
<TheLemonMan> seeing all those red crosses on the PR page makes me really sad
<andrewrk> TheLemonMan, I'm slightly annoyed at source hut for not using a more stable freebsd version
<andrewrk> the download page is still getting updated when everything else passes
<mikdusan> would be nice if they added a 12.1 image
Akuli has joined #zig
<andrewrk> if this continues for another day I'll disable freebsd builds entirely
<fengb> Just highlight all the breaking changes
<TheLemonMan> isn't 12 the latest stable release?
marmotini_ has joined #zig
<mikdusan> i'm not sure exactly but their 12.1 image somehow fails with pkg commands, and yet "uname -r" matches my vm, and my pkg commands seem to work
<TheLemonMan> maybe your pkg is new enough to include the patch that fixed the problem
<andrewrk> IMO it's source hut's responsibility to choose a working version of freebsd
<andrewrk> and it's zig's responsibility to choose a working CI
<TheLemonMan> a lot of CI services are affected by that problem
<TheLemonMan> shit happensโ„ข
<andrewrk> yeah I'll give it a couple more days
marmotini_ has quit [Read error: Connection reset by peer]
<Guest20151> Assertion failed at /deps/zig/src/list.hpp:31 in at. This is a bug in the Zig compiler.
<Guest20151> can we make it that this does not happen when simply moving a number of defs to new files and renaming them and all references.... too often when i want to refactor things a bit and clean up, becomes a battlefield
<TheLemonMan> good job, you broke it
<andrewrk> Guest20151, yes, we can fix all the bugs
<andrewrk> it will just take time
dimenus has joined #zig
<Guest20151> here's a hint if someone wants to glimpse at your list.hpp:31. i had a couple .zig files all `pub usingnamespace @import`ing a single .zig file (which exists) that itself `pub usingnamespace @import`ed one which.. didnt exist (renamed) :D
<Guest20151> maybe can do a repro later
<TheLemonMan> without a repro there's little or no chances for this bug to be fixed
<Guest20151> somehow hexchat irc lost my nick, brb. yeah i put a repro in my todo.txt, cant lose flow now =)
Guest20151 has quit [Quit: Leaving]
metaleap has joined #zig
<TheLemonMan> bleh, a lot of std.target.VersionRange stuff ends up in freestanding binaries
jjido has joined #zig
<andrewrk> in release builds? that should not be the case
<andrewrk> in debug builds, functions called at compile time get runtime versions generated as well. I believe there is an open issue for this. it's tricky because, maybe you wanted to call that function in a debugger?
<TheLemonMan> yeah, this is related to the missing way to mark some functions as comptime-only
<TheLemonMan> maybe with a custom calling convention enum?
<andrewrk> that's an important issue, not sure how to solve yet
<andrewrk> that's a nice idea
<andrewrk> that might even solve #425 as well
<mikdusan> oooh does that mean if a fn is marked comptime-only, I no longer need to `comptime callme()` ?
<TheLemonMan> that's the idea, I sprinkle `comptime` everywhere because I'm never sure
<andrewrk> mikdusan, more like `wants-to-be-comptime`
<andrewrk> if all the parameters are comptime, then it comptime-calls the function
<andrewrk> you would almost certainly want this for all pure functions
<mikdusan> ^^ with master or with this new feature in mind?
<andrewrk> with this new feature in mind
<andrewrk> I think I'm sidetracking the conversation though, because the thing I'm talking about is not really a calling convention, whereas TheLemonMan's idea is
<andrewrk> if something *must* be called at comptime, that is a calling convention. it cannot be called at runtime with a different calling convention
<andrewrk> however all this os version range stuff would not be comptime only
<andrewrk> and even with "wants-to-be-comptime", it would still leave the issue of generating unneeded runtime functions in debug builds
<andrewrk> so there are a few different but related things here
<andrewrk> I haven't thought of an elegant solution yet
_Vi has quit [Ping timeout: 272 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzzโ€ฆ]
mixi_ has joined #zig
mahmudov has joined #zig
dimenus has quit [Read error: Connection reset by peer]
hugbubby has joined #zig
<hugbubby> I'm getting the error "container 'std.heap' has no member called 'page_allocator'
<hugbubby> Trying to use the code suggested in teh Choosing your Allocator documentation. Does page_allocator not actually exist?
<hugbubby> the line is: var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
<metaleap> using a real old version per chance hugbubby?
<hugbubby> 0.5.0 sayeth zig version
mixi has quit [Quit: mixi]
mixi_ is now known as mixi
<metaleap> yeah 0.5.0 is severely out of date, in that version it was called `direct_allocator` if you're reading langref.html pick the one for 0.5.0
<fengb> It was added semi recently past 0.5.0
<hugbubby> I'll install gentoo's -9999
<andrewrk> good plan
<andrewrk> next release is april 13th btw
<andrewrk> it's coming right up
jjido has joined #zig
<hugbubby> lit
<hugbubby> how many ppl here also use gentoo, just wondering
<waleee-cl> *chirp chirp*
<hugbubby> lol
<waleee-cl> great system, but not enough compiletime
<waleee-cl> (and this is the one and only channel where that needs to be disambiguated from comptime :) )
<alexnask> lol
<andrewrk> with mingw-w64 v6.0.0 => v7.0.0: 391 files changed, 45611 insertions(+), 92832 deletions(-)
<andrewrk> they've really done a lot of cleaning and consolidation
<alexnask> nice
<andrewrk> that's for arm, aarch64, i386, and x86_64 btw
<hugbubby> How do I unsafely access freed heap memory w/ zig uwu
<hugbubby> promise that's what I want to do
<andrewrk> mingw-w64 is the only libc zig ships where we don't have to do a bunch of chores to make it multi-arch
<TheLemonMan> does it still compile for i386? I remember having to patch some header to make it compile with clang
<TheLemonMan> hugbubby, use a pointer?
<hugbubby> It's segfaulting >.<
<andrewrk> don't take this the wrong way, I'm just excited to use this idiom...
<andrewrk> play stupid games - win stupid prizes
<alexnask> :D
<TheLemonMan> show some code
<TheLemonMan> maybe you're getting a SIGBUS after a page is unmapped
<andrewrk> TheLemonMan, do you remember any words from the commit message?
<andrewrk> or files that it touched
<andrewrk> found it: f83bb3dd9e68899ca39cdddb7d84c2ad1c833d55
dimenus has joined #zig
<dimenus> andrewrk: I am not able to replicate joachimschmidt's issue with tetris
<dimenus> it compiles quickly and without issue
<andrewrk> dimenus, I think it depends on system c .h files
<andrewrk> also zig caches @cImport
marijnfs has joined #zig
<wilsonk> anybody else getting an error when trying to build the clashproto game on linux? The cross compiled version for windows-gnu builds and runs fine, but I get a 'c import failure' for soundio/soundio.h and an error about 'container "c" has no member SDL_SetHintPriority' also?
ur5us has joined #zig
<andrewrk> wilsonk, make sure your zig version is updated and you have all the dependencies installed on your system
<andrewrk> this is exactly the thing a package manager will solve fwiw
<fengb> Which will have a prototype ready by next release ;)
<andrewrk> the windows build is working because those dependencies are using packages
<wilsonk> oh, I thought it was just 'supposed to work' out of the box the way it was written
<andrewrk> yeah, on windows
<andrewrk> it doesn't have sdl2 and libsoundio packaged for other OS's yet
<hugbubby> http://dpaste.com/15GJ1B2 <-- this is the code taht triggers segfault instead of just going for dat sweet unsafe data
marijnfs_ has joined #zig
marijnfs has quit [Ping timeout: 258 seconds]
<wilsonk> ok, so the second error goes away once I installed the dev version of libsoundio. Works fine now. Thanks
<fengb> hugbubby: freeing memory also sets the space to undefined: https://github.com/ziglang/zig/blob/master/lib/std/mem.zig#L239
<fengb> In debug mode, this is 0xaaaaaaaa
<hugbubby> Is there a way I can free w/out setting space to 0
<hugbubby> *undefined
<hugbubby> Or is this a behavior of all allocators
<fengb> Um... that'd be a use-after-free bug. What's the usecase?
<andrewrk> ArenaAllocator doesn't yet have a way to "reset", while keeping all the memory reserved. that would be a nice API addition
<fengb> Actually in this case I think it's probably page_allocator punting the page back to the OS
<mikdusan> I think maybe you'll have to make your own allocator that does not markup after free
<andrewrk> but it would certainly @memset everything to undefined
<hugbubby> Atm the use case is I'm deliberately attempting to do that bug ;p, but also I would think memsetting upon free is a little costly speed wise
<hugbubby> Isn't it?
<andrewrk> yes it is. debug mode pays a lot of cost to gain easier debugging
<hugbubby> Can you disable debug mode?
<andrewrk> you can also disable it in a given scope
<shakesoda> arenas are much more useful if you can reset them
<shakesoda> that's something I do a fair bit in games
<hugbubby> I'm actually compiling --release-small, so presumably andrewrk is correct and that's not the issue
<fengb> Try using a FixedBufferAllocator instead of page_allocator
<fengb> I think it might be arena.deinit / page_allocator.free actually returning the page back to the OS
<andrewrk> hugbubby, check the implementation of ArenaAllocator. it unmaps everything on deinit
<hugbubby> thas prob correct
<mikdusan> fengb: no, currently @memset(undefined) is for all allcoators
<fengb> Right but his usecase is just dereferencing the address, which shouldn't cause a seg fault if it's still mapped
<fengb> I'd expect garbage instead of a hard crash
<mikdusan> fengb: but I should point out that's only for the free/destroy's ... deinit is a different story.
<hugbubby> So.... Does --release small @memset or not. I'm still in the dark here
<andrewrk> hugbubby, if you're using std.mem.Allocator interface, free() and destroy() are defined to make the memory contents undefined and whether or not memory access will trap is allocator-implementation-defined
<metaleap> usingnamespace must always have an operand resolving to a struct right? or any container? (all containers can have decls after all)
<andrewrk> so your use case is deliberately thwarted by the Allocator interface
<andrewrk> your use case requires resorting to non standard hacks
<metaleap> (asking for my ast traversals driving the wip LSP prototype =)
<mikdusan> thwarted is one of those words if you read more than once, it stops looking like a real word
<andrewrk> metaleap, any container
<metaleap> andrewrk thx
<hugbubby> memsetting freed memory seems like its a little handholdey to me tbh
<TheLemonMan> handholdey? people want even more safety
<mikdusan> same can be said for array bounds checking
<fengb> We might as well use a GC at this point
<hugbubby> ^
<hugbubby> should be the allocator's choice
<fengb> Real programmers write to empty bus
<mikdusan> hugbubby: iirc there was talk of moving the responsibility of @memset(undefined) to allocator implementation
<andrewrk> https://github.com/ziglang/zig/issues/4298 makes it allocator-implementation-defined
<mikdusan> see that? i just mention it and boom. autolinked!
<andrewrk> that was a re-paste too, I'm so good I linked it before you even said it :P
<alexnask> :D
<mikdusan> ahh i missed the first one oh my
<andrewrk> my fault for posting a URL with no summary
<hugbubby> I just figure ppl who are going to make their own allocator are also the high frequency trading types who dislike array bounds checking and memsetting unused memory to 0
<hugbubby> so they can get that 10ns performance boost
<TheLemonMan> I wrote my own allocator and I do like safety features
<mikdusan> hugbubby: the good news is that an allocator could condition on build-mode for reset policy
<hugbubby> ^ see that'd be nice
<mikdusan> but we're at version 0.5.0 still
<mikdusan> patche welcome
<mikdusan> *s
<hugbubby> What do you guys plan to use zig for?
<BaroqueLarouche> Games mostly
<andrewrk> BaroqueLarouche has a tutorial repository on making game boy advance games in zig
<mq32> hugbubby: anything lowlevel
<companion_cube> sat solvers!
marijnfs has joined #zig
marijnfs_ has quit [Ping timeout: 268 seconds]
<andrewrk> I'm going to rewrite my node.js music player server in zig, make a digital audio workstation, an arcade game, experiment with evolving digital organisms, build my static websites, and all the rest of the open source projects in my entire life
<hugbubby> Maybe when I get rich I'll spend my free time rewriting bloated slow linux ecosystem components in zig idk
<hugbubby> Like my terminal emulator
<TheLemonMan> systemd but written in Zig
<mikdusan> hugbubby: which term emulator is that
<hugbubby> urxvt
<marijnfs> something like that in zig would be pretty nice
<hugbubby> If one of you guys write a term emulator in zig that allows copy paste + transparency I will unironically use it
<hugbubby> Just make sure it doesnt trample on any of tmux's domain, so no tabs/other bullcrap
<companion_cube> tabs are good :-ยฐ
<fengb> Spaces are better ๐Ÿ™ƒ
<companion_cube> heh, yeah, but not in terminals
<hugbubby> Tmux in one term for me. Tabs=cope
<shakesoda> tabs > getting impaled > spaces > terminal tabs
* shakesoda runs
<andrewrk> what did I do to deserve a tabs v spaces discussion happening today
<shakesoda> hah
<BaroqueLarouche> haha
<TheLemonMan> tabs are 4 spaces, therefore tabs > spaces
<mikdusan> I have no idea why you guys are talking about an old softdrink
<shakesoda> my tabs may be 3 spaces, but the logic still checks out
<marijnfs> shit, thats pretty good
<fengb> I had a friend argue that tabs are 3 spaces. He is no longer a friend
<shakesoda> uh oh
<hugbubby> the garbage collectors want you to use terminal tabs
<companion_cube> I like my tabs to be $(random 3 5) spaces
<TheLemonMan> tabs are &ts spaces
<hugbubby> they also want you to use many instances of the same terminal like a barbarian instead of one tmux term
<fengb> Has anyone used fibonacci tabstops? :P
<companion_cube> wait, do you only have one terminal?
<hugbubby> I have one terminal. Every time I open a terminal, it either creates a tmux session or attaches to the existing one. I create new windows/splits when I need to do new things, like I do with a browser
<hugbubby> It's the way god intended
<shakesoda> i just make more terminal windows if i need them
<shakesoda> they even get allowed to do barbaric things like overlap
<companion_cube> hugbubby: ah but you still have multiple terminal windows? ๐Ÿ˜Œ
<fengb> I don't actually run executables. They're all applets running in my browser
<hugbubby> I do not. I have the one, 99% of the time. Its basically useless
<hugbubby> The only time I use the second behavior is when I go to a different tty with alt-fn-x
<TheLemonMan> everyone knows productivity scales linearly with the amount of terminals open
<alexnask> andrewrk, I think my PR broke the stage2 build >.< http://prntscr.com/rc8h5y
<hugbubby> Just realized andrewrk is the guy
<hugbubby> thx for the lang, I like making excuses to code in low level languages and you have enabled me
<alexnask> Not sure how we get to that realloc without getting to realloc with old_count=0 and new_count=2 though Im looking into it
<alexnask> new_count=1*
<mikdusan> somebody is hammering the merge button
<alexnask> Also not sure how it passed the tests on my machine and on the CI servers
<alexnask> :p
<andrewrk> alexnask, building stage2 isn't covered by tests currently, it's bit rotted a bit
<andrewrk> I was just about to go in there and freshen things up
<andrewrk> hugbubby, glad to hear it
<mikdusan> alexnask: please tell me that's not how your fonts looks and is an artifact of image uploading
<TheLemonMan> antialiasing is for the weak
<mikdusan> ah yeah I got the same crash with `zig build --help`
<tdeo> should the std.os wrapper for sendmsg set the MSG_DONTWAIT flag on the header with an event loop instance? it currently doesn't, so it seems like non-blocking io won't work with it automatically
<tdeo> oh never mind that :( i think this wrapper was added my me in my local branch a few weeks ago and i forgot about it
<tdeo> (but should it? i want to pr this when i'm done)
marijnfs_ has joined #zig
marijnfs has quit [Ping timeout: 240 seconds]
<mikdusan> alexnask: so on your crash: try reversing 371c21aa70fc61ef703e34079ce6de6c52ec91df
hugbubby has quit [Ping timeout: 268 seconds]
<alexnask> Yeah the thought crossed my mind although I think the issue is that we are only allocating src_fiel_count on the struct_val and not src_field_count + gen_field_count
<alexnask> So I will try that first
<alexnask> Or something like that
<TheLemonMan> hm, gen_field_count should always be <= src_field_count
<mikdusan> ok I regressed something.
marijnfs has joined #zig
marijnfs_ has quit [Ping timeout: 260 seconds]
<TheLemonMan> alexnask, I'm still seeing #3878 in #4619 :(
<TheLemonMan> I've applied your patch to the tuple_mult code path but the deref fetches an undefined value
<alexnask> Weird, my tests use values from a tuple passed as a comptime var parameter
<TheLemonMan> the problem is still there if you try to cast the result of an addition between two tuples to an array :\
<TheLemonMan> it's like the resulting fields are never written back to the result_loc
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzzโ€ฆ]
<alexnask> mikdusan, I think my commit is the problematic one, testing a couple of ideas and will let you know asap I have something
<mikdusan> alexnask: no probs. I'm putting some hooks on that container usage to see if I can prove/disprove safe-to-put-into-arena
marijnfs_ has joined #zig
marijnfs has quit [Ping timeout: 265 seconds]
marijnfs_ has quit [Read error: Connection reset by peer]
<andrewrk> alexnask, I think checking the AST node is a smell
Akuli has quit [Quit: Leaving]
<andrewrk> gonna revert that for now, sorry
<alexnask> Ofc
<TheLemonMan> andrewrk, if I have an "empty" result_loc with a struct type that's initialized as undefined, now if I fill it in field-by-field do I have to somehow reset its undefined state first?
<andrewrk> by empty do you mean ResultLocIdNone?
<TheLemonMan> yep
<andrewrk> ResultLocIdNone means there is no parent result loc, and if there needs to be a result location, then it will be created as a temporary (as a stack variable). For examle, the result location of a function call parameter
<andrewrk> I'm not sure I follow- in zig semantics, an undefined struct means all the fields are undefined. so if you define all the fields then the struct is no longer undefined
<TheLemonMan> yeah, that's what I expected, but even though I'm filling in this structure all I get back is `undefined`
<andrewrk> in the compiler guts, you would need to set the ZigValue::special to not be ConstValSpecialUndef anymore on the struct value
<andrewrk> but I would expect that to happen when the fields are allocated
<andrewrk> hmm this is making me realize that my plan for how to safety detect undef of structs at runtime is flawed
<TheLemonMan> there's something that's not setting that flag then :\ no idea where the problem is tho
<andrewrk> it should be when x_struct.fields is allocated
<andrewrk> similar to expand_undef_array - the value itself no longer becomes undefined, and each field becomes undefined instead
<TheLemonMan> I only create the type and let the result location allocate a slot for it
<andrewrk> I can look into it in a bit
<TheLemonMan> sure thing, I've hit a few dead ends while trying to debug this problem and am a bit stumped
alexnask_ has joined #zig
Sphax has joined #zig
alexnask has quit [Ping timeout: 240 seconds]
alexnask_ is now known as alexnask
doublex_ has quit [Quit: Leaving]
<mikdusan> 1 liner: nuke their file which overrides "quarterly" to "latest"
doublex has joined #zig
doublex_ has joined #zig
recombinant has joined #zig
doublex_ has quit [Remote host closed the connection]
<andrewrk> ๐Ÿ‘ ๐Ÿ‘ ๐Ÿ‘
Sphax has left #zig ["WeeChat 2.4"]
<andrewrk> now to find out if we've broken freebsd in the last 3 days
<mikdusan> I'll check my local vm
<TheLemonMan> I'm logging out for today, if you have any news about the result_loc thingie please write it down in the PR
<mikdusan> confirmed: `install` fails same error on my freebsd vm
<TheLemonMan> peace
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<andrewrk> peace
<andrewrk> mikdusan, when in doubt, don't put stuff in the arena. basically anything that needs the concept of "reallocation" should not go in the arena
marijnfs has joined #zig
<marijnfs> for (var i = 0; i < 10; i += 1) {} gives me: Expected expression, found var
<marijnfs> howcome
<alexnask> This is not zig code :-)
<alexnask> you want `var i = 0; while (i < 10) : (i += 1) { }`
<marijnfs> ah k
<marijnfs> i was grepping zig code, but now see it was javascript:)
<fengb> Proof that zig is inferior to JS? ๐Ÿ™ƒ
<alexnask> :D
recombinant has quit [Quit: Leaving]
Sphax has joined #zig
<marijnfs> If i dont define var i : i64 = 0 i get issues
<marijnfs> just var i = 0; gets me error: variable of type 'comptime_int' must be const or comptime
<marijnfs> :O
Sphax has quit [Client Quit]
<alexnask> a right mb
Sphax has joined #zig
<alexnask> literals are comptime only types
<alexnask> integer literals are comptime_int which is a comptime only type **
marijnfs has quit [Ping timeout: 240 seconds]
marijnfs has joined #zig
<marijnfs> what is the comptime literal, the '0'?
<alexnask> Yes, 0 is an integer literal :)
marijnfs_ has joined #zig
marijnfs has quit [Ping timeout: 255 seconds]
metaleap has quit [Quit: Leaving]
<marijnfs_> can't comptime be assigned to a runtime var?
<marijnfs_> other way around I understand is not possible, but this seems strange
<alexnask> marijnfs_, comptime_int, type, comptime_float are comptime-only types
<alexnask> But comptime_int and comptime_float can be casted to regular types (they coerce to integer/fp types)
<alexnask> marijnfs_, If you explicitly make a comptime u64 (for example) you can implicitly use it in a runtime context
<mikdusan> andrewrk: weird. I needed to do the same thing 1141bfb21b82f8d3fc353e968a591f2ad9aaa571 to FreeBSD
<andrewrk> mikdusan, that's good to know