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/
curtisf has quit [Ping timeout: 260 seconds]
avoidr has quit [Quit: leaving]
<scientes> $ git grep ZigTypeFn
<scientes> all_types.hpp:struct ZigTypeFn {
<scientes> all_types.hpp: ZigTypeFn fn;
<scientes> hmmm
<scientes> oh nvm ZigTypeIdFn
mikdusan3 has left #zig ["WeeChat 2.3"]
mikdusan has joined #zig
<zxrf> i get a segfault when i run zig fmt --some-unknown-flag
<zxrf> looks like we reach some invalid address when dumping the stack trace
dewf has left #zig ["Leaving"]
hspak has joined #zig
<scientes> oh that libuserland.a stack trace always locks up my computer, i disable it for debuggin purposes
<zxrf> gdb says it's at std/debug.zig:265
marijnfs has joined #zig
marijnfs__ has quit [Ping timeout: 244 seconds]
<hspak> Hello! Random Q from a new user: why are builtin functions camelCase? It looks like Zig’s preferred style is snake_case
tgschultz has quit [Read error: Connection reset by peer]
tgschultz has joined #zig
<Tetralux> I think there's an official style guide (although it's not enforced).
<Tetralux> But the short version last I checked
<Tetralux> Is that fns are camelCase, vars are snake_case.
<Tetralux> Globals are also snake_case.
<Tetralux> There's prob something I'm forgetting there, but... :)
<hspak> I see, thanks for the quick summary!
<Tetralux> Welcome :)
<Tetralux> Feel free to use your preferred style in your own code though.
<hryx> got another windows CI failure, this time I can't tell what: https://dev.azure.com/ziglang/zig/_build/results?buildId=2477
<hryx> at this point I'd better just get zig set up on windows for myself locally
st4ll1 has quit [Ping timeout: 244 seconds]
st4ll1 has joined #zig
darithorn has joined #zig
<mikdusan> and types prefer TitleCase
lunamn_ has quit [Ping timeout: 245 seconds]
lunamn has joined #zig
darithorn has quit [Ping timeout: 245 seconds]
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
fengb has joined #zig
laaron has joined #zig
companion_cube has quit [Remote host closed the connection]
fengb has quit [Ping timeout: 260 seconds]
hsp1 has joined #zig
hsp1 has quit [Client Quit]
_whitelogger has joined #zig
<hspak> I see in the docs "Zig does not special case string formatting in the compiler and instead exposes enough power to accomplish this task in userland."
<hspak> Does this mean that we can't format strings like we can with std.debug.warn out-of-the-box?
<hryx> hspak: nope, the standard library includes formatting. in fact, string formatting got improved this week
<hryx> note that instead of instead of C-style "%s" formatting it uses rust/python-inspired "{}" syntax
<hryx> hspak: sorry, reading back your question more closely -- yes, it's available out of the box, it's just implemented in the standard library instead of the core compiler
<hryx> it's just an implementation detail
<hspak> hryx: is there a zig equivalent of some_string = "foo.{}".format(bar) from python? Or format! from rust?
<hryx> yes if I understand, `std.debug.warn("{}", bar)`
<hryx> string literals don't support method syntax like your python example though
<hryx> agh, I'm sorry. I keep responding too fast. You're asking about assigning it to a string
<hspak> std.debug.warn prints to stderr. Can I save it to a string var somehow?
<hspak> np!
<hryx> To do so, you'll need to write it to a buffer
<hryx> the stdlib I believe does provide a way to do that. let me look up the function
<shachaf> I implemented {} formatting in C, it's great: http://slbkbs.org/tmp/fmt.txt
<hryx> hspak: here you go, you want `bufPrint` https://github.com/ziglang/zig/blob/master/std/fmt.zig#L1066
<shachaf> I was definitely wishing I had a better language when I was doing that.
<hryx> so you can't assign to a new variable, but you can fill a buffer you have allocated previously
<hspak> hryx: thank you! appreciate the help
<hryx> sure thing!
<hryx> very cool shachaf
rjtobin has quit [Ping timeout: 268 seconds]
brakmic has joined #zig
brakmic has quit [Ping timeout: 244 seconds]
brakmic has joined #zig
avoidr has joined #zig
_whitelogger has joined #zig
_whitelogger has joined #zig
hio has joined #zig
jjido has joined #zig
jjido has quit [Client Quit]
<emekankurumeh[m]> can zig cc compile objective c files out of the box?
<emekankurumeh[m]> with capability like `-fobjc-arc` add `-fmodules`?
jjido has joined #zig
st4ll1 has quit [Ping timeout: 272 seconds]
st4ll1 has joined #zig
<mikdusan> emekankurumeh[m]: fwiw i got a simple foo.m to compile with this command: https://gist.github.com/mikdusan/26acfa23bc21db01a60b2bf1490d23e5
_whitelogger has joined #zig
fubd has joined #zig
wootehfoot has joined #zig
<fubd> anyone have any code that converts zig strings to win32 wide strings?
<BitPuffin> I don't know why but for sem reason when I compile some C with Zig it complains that '\b' and '\0' aren't valid characters?
<Sahnvour> hryx: creation of libuserland failed, but there's no zig error message sadly
<BitPuffin> but it seems to mainly be doing so in the C file I specified in the addExecutable
<BitPuffin> in that one it even considered tab an error
<BitPuffin> as if it was Zig
<BitPuffin> but it would fail much sooner if it wasn't compiling it as C
<BitPuffin> so I'm dazzled
<BitPuffin> or bedazzled
<BitPuffin> idk english even
very-mediocre has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ky0ko has quit [Read error: Connection reset by peer]
<Sahnvour> hryx: I tried to build it locally, no luck. I'm able to get verbose output up to zig ir pass, but not llvm ir pass
very-mediocre has quit [Remote host closed the connection]
st4ll1 has quit [Ping timeout: 245 seconds]
st4ll1 has joined #zig
jjido has joined #zig
geemili has joined #zig
redj has quit [Ping timeout: 244 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
redj has joined #zig
st4ll1 has quit [Quit: WeeChat 2.5]
fubd has quit [Remote host closed the connection]
very-mediocre has joined #zig
redj has quit [Ping timeout: 258 seconds]
Akuli has joined #zig
very-mediocre has quit [Remote host closed the connection]
HelloThere54321 has joined #zig
<HelloThere54321> is it possible to use the pseudo_struct globally
laaron- has joined #zig
laaron has quit [Ping timeout: 260 seconds]
redj has joined #zig
ajhager has joined #zig
redj has quit [Read error: Connection reset by peer]
companion_cube has joined #zig
dimenus has quit [Remote host closed the connection]
<emekankurumeh[m]> fudb std.unicode should have the functions you're looking for
<tgschultz> HelloThere54321, why wouldn't it be? I don't understand the question.
fubd has joined #zig
ajhager has quit [Ping timeout: 260 seconds]
Ichorio has joined #zig
fubd has quit [Ping timeout: 260 seconds]
darithorn has joined #zig
<scientes> wtf, almost everything in zig is passed by reference
<scientes> it should all be passed by value, like in C, and then LLVM can do the calling convention (as the PowerPC backend does), and we can fix it up for x86 and arm
jjido has joined #zig
<emekankurumeh[m]> <tgschultz "HelloThere54321, why wouldn't it"> isn't zig free to pass by value or by reference because it doesn't have a defined calling convention?
<scientes> i'm talking about extern functions
<scientes> but it even does it for fastcc functions and then lets llvm clean up after it
<scientes> which is incorrect
<scientes> fastcc is the llvm name for zig-internal functions
<scientes> from my position it is just really tedious to have to allocate memory to just pass a bool
<scientes> (in the compiler)
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
very-mediocre has joined #zig
Ichorio has quit [Ping timeout: 264 seconds]
fsateler has quit [Quit: ZNC 1.7.2+deb2 - https://znc.in]
Ichorio has joined #zig
fsateler has joined #zig
fsateler has quit [Remote host closed the connection]
very-mediocre has quit [Remote host closed the connection]
<marler8997_> scientes: not sure what you're talking about, can you provide an example function?
Ichorio has quit [Ping timeout: 250 seconds]
jjido has joined #zig
ianlilleyt has joined #zig
darithorn has quit [Ping timeout: 258 seconds]
<scientes> marler8997_, ?
<scientes> oh i see
<scientes> yeah its only applicable from inside the compiler marler8997_
<scientes> not the zig language
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
darithorn has joined #zig
fsateler has joined #zig
fsateler has quit [Remote host closed the connection]
<emekankurumeh[m]> and then that memory is never freed?
Ichorio has joined #zig
Akuli has quit [Quit: Leaving]
reductum has joined #zig
marijnfs_ has joined #zig
Ichorio_ has joined #zig
<tgschultz> HelloThere54321, Do you mean using pseudo_struct to like, try and construct a global union of all entities or something? In that case, no, I don't think that can be done.
<scientes> emekankurumeh[m], it is on the stack
<scientes> emekankurumeh[m], realize the zig language knows nothing of a heap
<emekankurumeh[m]> oh, i think I misunderstood what you meant
Ichorio has quit [Ping timeout: 252 seconds]
<scientes> i'm talking in the compiler
<scientes> everything has to go through a alloca on the stack
<emekankurumeh[m]> we `alloca` the bool and pass a reference to that?
<scientes> well it gets passed by value because of the C ABI, but its turned into a reference before that
<emekankurumeh[m]> gotcha
<scientes> we are just giving the llvm optimizer a lot of work to do
<scientes> things should only becomes references if 1) they are variables, or 2) the c abi requires it (but that is only in codegen.cpp)
redj has joined #zig
<scientes> as llvm has no concept of variables, it is SSA
<scientes> so you have to implement variables with stack assignments, and then have the optimizer figure it out
<scientes> however consts do not need to be stack allocated
<scientes> arrays also have to be
<scientes> but not structs, interestingly
<scientes> actually, i'm not sure about arrays
<emekankurumeh[m]> is there a way to get the value from an union without knowing the active tag?
<scientes> memcpy
<scientes> or just cast to [*]u8
reductum has quit [Quit: WeeChat 2.5]
ianlilleyt has quit [Ping timeout: 260 seconds]
brakmic has quit []
<Sahnvour> scientes: is swizzling planned for vector types ?
<scientes> Sahnvour, that is what @shuffle does?
<scientes> and there is a comptime implementation so it will do it for consts
<scientes> otherwise you have to do it in llvm
<emekankurumeh[m]> is `@Vector(_, u32)` valid zig?
<Sahnvour> hmm right, I was thinking about syntactic sugar over shuffle then, I suppose
<scientes> emekankurumeh[m], no it isn't, but it takes any length of vector
<scientes> so I didn't know how else to say that
<Sahnvour> I've seen multiple times people writing code to mimic shader languages' swizzling (vec.xyz etc.), so there is interest in this feature
<scientes> well zig can handle that sort of things pretty well
hspak has quit [Ping timeout: 244 seconds]
hspak has joined #zig
Ichorio_ has quit [Ping timeout: 264 seconds]
jjido has joined #zig
<scientes> #define if(x) if((x) && rand())
<scientes> hahahahaha
<hspak> Is there anyway to speed up the compile time of zig (the compiler itself)? It looks like it's only using a single core by default
<emekankurumeh[m]> `make -j4`?
<hspak> That works lol, thanks
ajhager has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
darithorn has quit [Quit: ByrdIRC]
<scientes> hspak, -GNinja to cmake
<scientes> then use ninja
darithorn has joined #zig
<emekankurumeh[m]> i use `ninja -j4` when building zig personally
<scientes> ninja automatically scales (however i scale it back so it doesn't bog down my computer)
redj has quit [Ping timeout: 258 seconds]
ajhager has quit [Ping timeout: 260 seconds]
ianlilleyt has joined #zig
wootehfoot has quit [Read error: Connection reset by peer]
ajhager has joined #zig
darithorn has quit [Quit: Leaving]
ianlilleyt has quit [Ping timeout: 260 seconds]
<hryx> Sahnvour: thanks for looking into the windows CI problem! It's starting to go beyond my expertise and I'm not sure where to go from here
<hryx> how did you generate those output files in your gist?
<Sahnvour> copy/pasted from visual studio debugger
<Sahnvour> it's especially unpractical because building a debug zig on windows requires a debug build of llvm which is a chore, but luckily I already had one
<hryx> oof, that sounds like it could take a while to set up
<Sahnvour> the llvm part takes around 2h on my machine iirc
<hryx> in these result_loc values, why are there +/- symbols? is it a diff?
<Sahnvour> I think the + is for struct variables that can be expanded to see the values of their members
<Sahnvour> I didn't expand everything obviously, but I hope there is some info that will be useful and maybe andrew will have an idea
<hryx> Ah, that makes sense. I can see how some are expanded, just not indented
<hryx> I may have to detour to a different issue till andrew returns
<scientes> hryx, what is he up to?
<hryx> I don't know
<scientes> oh ok
hio has quit [Quit: Connection closed for inactivity]
<hryx> has anyone found a lot of zig process sticking around for some reason?
<mikdusan> on windows?
<hryx> ps aux | grep zig-cache | wc -l <-- gives me 288
<hryx> linux
<hryx> the processes seem to be from build_runner.zig
ltriant has joined #zig
<hryx> huh. most of them seem to be sleeping (status S). I don't really know what that means
<hryx> anyway, only asking because I have the vscode zig extension and I frequently find my system slows way down till I do a `killall zig`
<hryx> (I do zig fmt on save so it spawns a lot of processes)
<mikdusan> hmm this is just a guess. but zig-cache manifest file access is mediated by file locking.
<mikdusan> i wonder if one zig proc got suspended and didn't let the lock go. others waiting for it.
redj has joined #zig
<hryx> hm, interesting. also notable is I have the nightly zig Snap package installed, although I almost only ever call my locally built one
<mikdusan> do you kill the procs already?
<hryx> yeah every once in a while
<hryx> I think I might have multiple issues happening, it's hard to tell
<mikdusan> next time if the proc is around use gdb to attach to one of the running procs
<hryx> well this is interesting. I just got an unreachable doing `zig fmt --stdin`. woof
<hryx> mikdusan: will do
<mikdusan> depending on how much has NOT changed in your source files, you might get a decent stack trace.
<emekankurumeh[m]> does anyone know of a way to output error notes (the extra info under error messages) in ir.cpp?
marijnfs_ has quit [Quit: WeeChat 2.4]
<hryx> mikdusan: very strange. My vscode extension is configured to call my git cloned zig for formatting, but these lingering processes are all from my Snap installation (which is in my PATH)
<hryx> not sure why/where those are even being called
_whitelogger has joined #zig
<scientes> hryx, i'm using the same extension and don't have that problem
<scientes> but it isn't spawning zig fmt probably cause it can't find it