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/
mahmudov has quit [Ping timeout: 265 seconds]
<Snektron> Considering whether i should generate Zig code directly or through std.zig.ast
<BaroqueLarouche> First pull request! https://github.com/ziglang/zig/pull/4137
ltriant has joined #zig
return0e_ has joined #zig
return0e has quit [Ping timeout: 240 seconds]
<mikdusan> my brain must be fried. Is 4137 just renaming variables?
<BaroqueLarouche> No, when looking for executable in your $PATH on Windows, it was using $CWD + the command you passed to spawnWindow
<mikdusan> thanks I missed it
JX7P has joined #zig
ltriant has quit [Ping timeout: 258 seconds]
<fengb> https://www.reddit.com/r/zig why is the logo orange on orange now?
<daurnimator> fengb: orange on orange?
<daurnimator> I see orange on blue :P
<daurnimator> But also: "why is it blue" is a great question.
<daurnimator> The answer to both of them may just be: the background is transparent. Seems like different browsers render it differently?
<fengb> Maybe we should fix the background image for the reddit upload
<daurnimator> normal reddit for me: https://imgur.com/0Woxpl6.png
<daurnimator> dark mode: https://imgur.com/LdbngkX.png
ltriant has joined #zig
ltriant has quit [Ping timeout: 260 seconds]
traviss has joined #zig
dddddd has quit [Ping timeout: 240 seconds]
ltriant has joined #zig
idxu has joined #zig
ltriant has quit [Ping timeout: 265 seconds]
adamkowalski has joined #zig
adamkowalski has quit [Remote host closed the connection]
adamkowalski has joined #zig
adamkowalski has quit [Remote host closed the connection]
ltriant has joined #zig
ky0ko59 has joined #zig
ky0ko has quit [Disconnected by services]
ky0ko59 is now known as ky0ko
ltriant has quit [Ping timeout: 260 seconds]
ltriant has joined #zig
ky0ko has quit [Ping timeout: 240 seconds]
ltriant has quit [Ping timeout: 265 seconds]
knebulae has quit [Read error: Connection reset by peer]
BaroqueLarouche has quit [Quit: Connection closed for inactivity]
ltriant has joined #zig
ltriant has quit [Ping timeout: 240 seconds]
ltriant has joined #zig
ltriant has quit [Ping timeout: 268 seconds]
knebulae has joined #zig
knebulae has quit [Client Quit]
knebulae has joined #zig
Astronothing has joined #zig
schme245 has joined #zig
ltriant has joined #zig
ltriant has quit [Ping timeout: 268 seconds]
Snetry has quit [Quit: left Freenode]
Snetry has joined #zig
ur5us has joined #zig
<daurnimator> oooo, would be cool to have creationix on board :)
mahmudov has joined #zig
Astronothing has quit [Ping timeout: 265 seconds]
lunamn___ has joined #zig
schme245 has quit [Remote host closed the connection]
lunamn_ has quit [Ping timeout: 260 seconds]
ltriant has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
ltriant has quit [Ping timeout: 268 seconds]
<mq32> Semantic Analysis [971/982] /home/felix/projects/softrenderlib/src/main.zig:116:31: error: expected type 'enum:69:45', found 'enum:69:45'
<mq32> huh :D
schme245 has joined #zig
m4ho has joined #zig
schme245 has quit [Remote host closed the connection]
maerwald has joined #zig
dddddd has joined #zig
<wilsonk> mq32: I had an error like that a while back...did you figure it out?
<mq32> i know how to provocate it
<mq32> it's about implicitly defined enums in function parameters
<wilsonk> I can't remember what it was for me...but I think my case was fixed
<wilsonk> file an issue? Or is there an existing one?
<mq32> mikdusan: you ninja'd me!
<mikdusan> hahah
<mikdusan> i just saw that
<mikdusan> also `comptime foo(.a);`
<mq32> btw, some late-night hack with zig:
<mq32> software-rasterization
ltriant has joined #zig
ltriant has quit [Ping timeout: 260 seconds]
mahmudov has quit [Remote host closed the connection]
mahmudov has joined #zig
_whitelogger has joined #zig
<mq32> huh
<mq32> i think i found a kinda weird bug
<mq32> if you write some runtime code in @bitCast, it will fail to compile because zig tries to enforce comptime eval
_Vi has joined #zig
<mq32> looks like nobody tests the http module D
<traviss> there are tests for http/headers but i don't see std/http imported anywhere.
<maerwald> wanted to use zig for a relatively simple cli program that does some file operations, downloading and extracting tarballs, as well as parsing a few config files
<maerwald> but no http module :o
<scientes> maerwald, cli is harder as there is no translation facilities in zig ATM
<scientes> or even a gnu-style argument parsing facility
BaroqueLarouche has joined #zig
schme245 has joined #zig
ltriant has joined #zig
ltriant has quit [Ping timeout: 258 seconds]
BaroqueLarouche has quit [Quit: Connection closed for inactivity]
<m4ho> Hi, I am starting with zig just now and I started with the documentation. I installed zig-0.5.0 via pacman (Distro is majaro) and compiling the hello world example throws multiple errors, the following being the second: http://ix.io/277i Am I doing something wrong?
BaroqueLarouche has joined #zig
Astronothing has joined #zig
<Snektron> m4ho, std.io.getStdOut returns a so-called "error union"
<Snektron> so its basically an error or another type
<Snektron> you have to unwrap the error with the try keyword
<Snektron> in a single line you can write `const stdout = &(try std.io.getStdOut().outStream().stream;`
<Snektron> Although you might be creating a dangling reference
<Snektron> also i forgot a closing parenthesis after getStdOut()
<mikdusan> fyi, zig master both `getStdOut()` and `getStdErr()` no longer can fail, so no error union
<m4ho> mikdusan and Snektron: Thank you, I think I got it
<m4ho> And apparantly I should not start learning the language with something else than the master
schme245 has quit [Remote host closed the connection]
<mq32> grah. and i ran against into the problem with packed structs :(
<mq32> via, i saw that you tried to do the same approach as me on fixing the packed structs problem
<shakesoda> #1717 pushed back to 0.7.0 -> :(
<mq32> sad, but reasonable. the 0.6 release is a under the term "stability/safety release"
<shakesoda> makes sense
<shakesoda> i just really want that particular change
<mq32> hehe, i want it too, but what i really really want is that packed structs work with 3-byte-sized types :D
doublex has quit [Ping timeout: 258 seconds]
<mq32> i have now 4 projects that semiish block on this
<mq32> for the current project i could trivially work around it, but it's not that easy in other projects
<shakesoda> as in you can't define an i24/u24 that packs correctly?
<mq32> yep :D
<shakesoda> frustrating!
<mq32> just spawn more projects!
<scientes> shakesoda, just define it with methods
<scientes> it isn't that hard
<shakesoda> ?
<scientes> const packed_u24 = struct { data: u24, fn get(n: usize) u24 {...}}...
<scientes> uggh, that isn't right
<scientes> but anyways, it can be done
<scientes> more like array_of_u24 = ...
<scientes> and you generate the struct with a function
<scientes> it is more advanced zig, but it can be done
<mq32> scientes: [2]u24 is 8 byte large, not 6
<mq32> that's the problem ;)
<scientes> yeah but you can do it
<mq32> and as soon as this gets too complicated, it isn't worth the time to write horribly maintainable code just "to get it work"
<mq32> at least that's my current strategy
<scientes> mq32, just use [6]u8
<scientes> and then you also have to manage endianness
<mq32> nope, that is also 8 byte large :D
<scientes> but it really isn't that bad
<scientes> no it isn't
<mq32> it is.
<mq32> trust me on this topic, i've already tried to fix the compiler in this regard
<scientes> WTF
<scientes> that makes no sense
<scientes> u8 is align 1
<mq32> yes, but the array isn't ;)
<scientes> so it should be size 6
<mq32> @sizeOf([6]u8) == 6
<mq32> but not in a packed struct, because the compiler messes up alignments
<shakesoda> can you flip this inside out and cast parts of a byte array to your u24 type as a workaround
<scientes> that doesn't make any sense still
<scientes> the array should only be the align of the most aligned member
<scientes> looks like a bug
<mq32> that's what i'm talking about!
<mq32> and the problem get's even more complex as soo as you have something like arrays of packed structs with non-power-of-two size
<mikdusan> arrays don't pack
ltriant has joined #zig
<mq32> yep, that's another "problem" right now, because you cannot model some stuff with that
<mq32> and use funky manual casting all the way around
<scientes> yeah that is a bug
<scientes> ^^^^^^ in C
doublex has joined #zig
<scientes> mq32, no it isn't a bug look https://godbolt.org/z/WEZHqh
<scientes> that said, I really know nothing about "packed"
<mq32> it is, for packed structs
<scientes> only extern and "extern packed" (which doesn't seem to be working right now)
<mq32> packed structs are defined as having *no* padding between elements
<scientes> yeah but there is also werid bit packing stuff
<scientes> and it looks underspecified so i'd just avoid it
<scientes> as we are now finding
<mq32> yeah but i need that bit packing stuff ;)
<scientes> but "extern packed" (which is what I always expect "packed" to be) doesn't seem to be working
<scientes> as C also has a packed mode
<mq32> and i cannot work around that other by writing a horrible mess of bit shifts
<scientes> which is a ABI
<mq32> C packed != Zig packed
<scientes> mq32, just use extern
<scientes> mq32, yeah but zig should also have C's packed
<mq32> and then do bit shifts?
<scientes> its another abi to support
<mq32> well, that's the point: i don't want to work around compiler bugs ;)
<mq32> just for the sake of "getting something" done
<scientes> mq32, you have to manually handle endianness
<scientes> but otherwise
<mq32> my point is: it isn't helpful to ignore compiler bugs and work around them
ltriant has quit [Ping timeout: 268 seconds]
<scientes> well zig is kinda like this these days
<mq32> but i've seen that via is trying to fix the same topic right now
<scientes> and I also got frustrated when patches I submitted to fix "TODO" and "FIXME" were fussied over
<mq32> the point is: i can just put any project that depends on new/buggy compiler features on hold
<scientes> when the compiler just quits over valid code, cause no-one has used it
<mq32> as nothing of it is relevat anyways except for testing out the limits of the language and the compiler
<scientes> such as using the error set merging features
<mq32> i have no benefit from doing a horrible amount of work just to reverse it two months later
<SyrupThinker> Well except for getting comfortable writing boilerplate
<SyrupThinker> I for one am writing all these bitshifts D:
<mq32> SyrupThinker: that's what i want to prevent in the first plaec :D
<mq32> i have made so many mistakes with those darn bitshifts
<SyrupThinker> Luckily some structures share layout :)
<scientes> mq32, just read a *u32 align(1), mask the extra byte, do an endianness flip
<scientes> however, llvm will now fix those bit shifts up to the above
<scientes> i believe
return0e has joined #zig
return0e_ has quit [Ping timeout: 258 seconds]
TheLemonMan has joined #zig
<TheLemonMan> mq32, have you tried using the new .Interrupt calling convention?
<mq32> TheLemonMan, nope, not yet
<TheLemonMan> you should be able to get rid of the common_isr_handler function with that
schme245 has joined #zig
<scientes> where is the docs for that
<scientes> there is nothing here https://llvm.org/docs/LangRef.html#callingconv
<TheLemonMan> the documentation is a bit sparse, there's https://lists.llvm.org/pipermail/cfe-dev/2015-September/045171.html and LLVM source code :P
<TheLemonMan> and it also works on AVR :D
<mq32> TheLemonMan, i don't think i can get rid of my common_isr_handler ;)
<mq32> it does more than just building a calling convention
<mq32> it is required for multithreading for example
BaroqueLarouche has quit [Quit: Connection closed for inactivity]
<TheLemonMan> who needs multithreading? no one! I tell you
<mq32> heh
<mq32> i also use it for context switches between different modes in my console :D
<scientes> why do you have to be so macho to do x86?
<scientes> why no do something saner, like ARM
<TheLemonMan> you're saving&restoring the registers clobbered by the handler, aren't you?
<mq32> TheLemonMan: i do more ;)
<mq32> scientes: i do x86, AVR, ARM, SPU Mk2 (#macho)
* scientes just noticed all these comments are in german
<scientes> das Offset
<mq32> yeah because i am a lazy and i just neer changed them after copying them :D
<scientes> are you sure it isn't der or die?
<mq32> TheLemonMan:
<mq32> \\ push %%esp
<mq32> \\ call handle_interrupt
<mq32> \\ mov %%eax, %%esp
<mq32> that allows changing the whole stack (thus: execution context) on return of the interrupt handler
<TheLemonMan> oh
<TheLemonMan> that's nasty heh
<mq32> also the register-saving allows modifying all registers via a struct pointer :)
* scientes always wondered how people chose genders when picking words from english
<scientes> do they just roll a dice?
<mq32> scientes: it's kinda a natural thing
<mq32> but it's also regional which gender words do have
<mq32> germany has two genders for "Butter"
* scientes hides
<scientes> mq32, did it need surgery for that?
<mq32> some people use "die Butter", some others use "der Butter"
<TheLemonMan> it's a smart way to fetch the state of the registers, I must admit
<mq32> officially it's "die Butter", but we southern germans don't really care about what "Der Duden" says
<scientes> are there any dialects that just use the same gender for every noun?
<mq32> no
<mq32> at least not that i know f
<mq32> *of
<mq32> german also has a "generic masculinum" which means that there are male words which do not actually refer to a gender
<mq32> like "Bäcker" which is Baker
<scientes> coming from English genders are wacky, and then differnt languages have different genders
<mq32> i can say "Sie ist Bäcker" (she is a baker)
<scientes> but aparently the same language has different genders
<mq32> fun thing is that immigrants learning german is that they mess up a lot of those word genders
<mq32> turkish has afaik only one gender for words, and russian has *different* genders for pretty much everything
<scientes> georgian also doesn't have gender
<scientes> Russian is very difficult indeed
<mq32> i find natural languages fascinating
BaroqueLarouche has joined #zig
Snetry has quit [Quit: left Freenode]
schme245 has quit [Remote host closed the connection]
schme245 has joined #zig
<via> mq32: yes, and the problem it currently has is fp load/stores, since it looks like the llvm types become single i8s
<via> i'm concerned what i see as two unrelated problems are getting put together -- ability to do individual field alignment, and having the right total size
<via> i'll admit i don't actually see the use case for individual field alignment control in a packed struct, and i think that massively complicates hte problem
<via> unfortunately i can't really take a look at it, i've got company for the weekend
ltriant has joined #zig
ltriant has quit [Ping timeout: 265 seconds]
rjtobin has joined #zig
<mq32> via: take your time and enjoy the weekend!
<mq32> i made a PCX/8bpp loader for zig :)
<frmdstryr> Does anyone use gdb with zig? How can I print a var from a non-global module?
mahmudov has quit [Ping timeout: 240 seconds]
rageoholic has joined #zig
<rageoholic> Hey I've got a question
<rageoholic> How can I tell zig's build system I need to put a dll (sdl in this case) and an executable in a distribution directory?
mahmudov has joined #zig
<TheLemonMan> frmdstryr, hm? what do you mean with non-global?
<frmdstryr> Not the root
<frmdstryr> eg "p osc.HSI_VALUE"
<frmdstryr> osc.zig is it's own file imported into main as const osc = @import("osc.zig")
<frmdstryr> even in debug mode pretty much everything seems to just say "optimized out"
<mq32> rageoholic: use Builder.addSystemCommand and depend on that step
yth has joined #zig
wilsonk has quit [Ping timeout: 268 seconds]
<frmdstryr> also for whatever it's worth i modified zig to compile with -Og and it doesn't seem to make any difference
Akuli has joined #zig
wilsonk has joined #zig
<mq32> frmdstryr: note that zig only emits what your code actually touches
<mq32> and pretty much all constants get agressivly inlined
terinjokes has quit [Ping timeout: 240 seconds]
<rageoholic> Please help out. I really want to use SDL but I have no idea how to set it up with zig
<frmdstryr> Yeah it seems to just inline every register access
terinjokes has joined #zig
<frmdstryr> in c i can just read a register with p RCC->CR, in zig i have to print the actual address
<frmdstryr> it'd be helpful if there'd be some way to turn this off for debugging
<TheLemonMan> uh that's interesting, I wonder if it's LLVM being too aggressive or we don't emit enough debug infos
riba has joined #zig
<rageoholic> ah ok
<mq32> use this, ask me questions, make improvements )
<mq32> but it also contains code examples on how to use the raw C api
<mq32> what's the state of the art allocator to be used in tests?
<rageoholic> Doesn't work on windows
<mq32> hm, if you figure it out how to do SDL on windows, please make a pull request
<mq32> i don't have a windows machine on my hands anymore
<rageoholic> In the meantime GLFW I guess
<rageoholic> Shame
<rageoholic> Was hoping to use SDL instead
<mq32> what's your problem with SDL?
<mq32> use a prebuilt version from the website, add include path and the library and it _should_ work
<rageoholic> How do I add the library?
<rageoholic> I tell it to link it but the exe can't find the dll
<mq32> yeah, then you have to copy the SDL.dll next to your executable
<mq32> same for glfw ;)
<TheLemonMan> frmdstryr, wrt your first problem maybe you're hitting https://github.com/ziglang/zig/issues/165
<rageoholic> Oh I statically link glfw
<rageoholic> And is there a way to copy it next to the exe with zig build?
<rageoholic> I want to automate this as much as possible
<rageoholic> Also is there a way to set the cwd of the run step?
<mq32> yes, yes
<mq32> use addSystemCommand in zig.build
<mq32> and read the source code of the build.zig stuff
<mq32> it really helps on knowing what it does
<rageoholic> Alright
ur5us has joined #zig
swoogan has joined #zig
traviss has quit [Ping timeout: 260 seconds]
<mikdusan> see `addInstallFile()` and a few of its specializations
<mq32> mikdusan: oh neat that this exists!
<mq32> we _really_ need some docs on the builder module :D
<mikdusan> *everyone steps back as mq32 /steps/ forward :)
Snetry has joined #zig
<mikdusan> my fav command for that: `cat lib/std/build.zig | grep 'pub fn' | sort`
<frmdstryr> TheLemonMan: Yes that looks like it
rageoholic has quit [Read error: Connection reset by peer]
scientes has quit [Quit: ZNC 1.7.5+deb1 - https://znc.in]
<frmdstryr> Also it's probably more of a issue of gdb not supporting zig than with zig itself
doublex has quit [Ping timeout: 240 seconds]
return0e has quit [Remote host closed the connection]
return0e has joined #zig
doublex has joined #zig
Snetry has quit [Quit: left Freenode]
Snetry has joined #zig
rjtobin has quit [Quit: Leaving]
<schme245> is there a way to detect what vector extensions are present when building a zig library?
TheLemonMan has quit [Ping timeout: 258 seconds]
<Astronothing> Hello, is there a way to initialize an array from a slice? I'm trying to do this: https://godbolt.org/z/mLERzA
ltriant has joined #zig
scientes has joined #zig
ltriant has quit [Ping timeout: 240 seconds]
<schme245> Astronothing: array have comptime known length, slices have runtime known length
<schme245> so there is no way to go from slice to array
<schme245> (I believe)
<mq32> you could dirtily pointer-cast around
<mq32> but i would make a helper function
<schme245> out of curiosity, how would that pointer cast look?
<mq32> fn sliceToArray(comptime T : type, input: []const T, comptime size: usize) ![size]T
<mq32> @ptrCast(*[N]T, &slice[x]).*
<schme245> neat
<mq32> i would go for that function
<schme245> is there anything ptrCast can't do? 😁
Snetry has quit [Quit: left Freenode]
<mq32> yeah, change alignment
<Astronothing> thank you!
Snetry has joined #zig
riba has quit [Ping timeout: 260 seconds]
Snetry has quit [Quit: left Freenode]
ur5us has quit [Ping timeout: 260 seconds]
<andrewrk> Astronothing, std.mem.copy
<andrewrk> I'm not sure why @ptrCast is being suggested
<Astronothing> yup, I'm struggling a bit with mem.copy at the moment
<andrewrk> after https://github.com/ziglang/zig/issues/863 is implemented, the line could be: const v = Foo{ .data = buffer[0..4].* };
<andrewrk> oh now I understand mq32's suggestion, which works around this issue not being implemented yet
<mq32> andrewrk, that syntax for slice-dereference is neat!
Snetry has joined #zig
* mq32 runs into wild integer overflows
traviss has joined #zig
Snetry has quit [Client Quit]
<traviss> schme245, i got 3 benchmarksgame solutions put up that are on par or slightly faster than the fastest c solutions. https://github.com/travisstaloch/zig_benchmarksgame
<schme245> traviss: that's awesome! :D
<traviss> believe there is room to improve the spectralnorm solution. wip
<schme245> we should try to get Zig into the official benchmarks game somehow
<schme245> good exposure
<traviss> yeah. i'm not sure how to get new solutions accepted. i was reading and they say they only want solutions for a given lang if its missing.
<traviss> so should be no problem for zig i hope.
<schme245> I believe opening an issue here is the way to go: https://salsa.debian.org/benchmarksgame-team/benchmarksgame/issues
<traviss> thanks! i'll see what i can do.
<andrewrk> schme245, tiehuis started working on that: https://github.com/tiehuis/zig-benchmarks-game
<schme245> traviss: please keep me posted! :)
wootehfoot has joined #zig
Snetry has joined #zig
Akuli has quit [Quit: Leaving]
<traviss> oh cool. thanks andrewrk
schme245 has quit [Remote host closed the connection]
ltriant has joined #zig
<pixelherodev> `cat lib/std/build.zig | grep 'pub fn' | sort` brilliant!
<pixelherodev> Can't believe I hadn't thought of that :)
ltriant has quit [Ping timeout: 265 seconds]
<mikdusan> andrewrk: if you get a chance push www.ziglang.org? there's a few examples that are out of date
blueberrypie has quit [Quit: leaving]
<andrewrk> mikdusan, yes will do
BaroqueLarouche has quit [Quit: Connection closed for inactivity]
_whitelogger has joined #zig
<pixelherodev> Okay, question: `const a = struct { var b: u8 = 38; };` is `b` there a global, or a namespaced member of a? Because after reading through GH Issues I no longer am sure I know :P
<mq32> it's a global variable in the namespace "a"
<pixelherodev> Ahh, okay
<pixelherodev> So `global` meaning storage location?
<mq32> yeah, pretty much
<pixelherodev> Gotcha
<pixelherodev> Thanks!
<Snektron> andrewrk, would you pick std.zig for source generation or just straight up print a source file?
<Snektron> also, moreover std.zig, why is as an ast tree returned as a pointer to memory owned by itself instead of as a value type?
<Snektron> and why are nodes implemented by a knock-off discriminated union instead of union(enum)
swoogan has quit [Ping timeout: 260 seconds]
ltriant has joined #zig
ltriant has quit [Ping timeout: 268 seconds]
schme245 has joined #zig
swoogan has joined #zig
<mq32> do we have some kind of lock-free queue/channel in zig.std already?
wootehfoot has quit [Read error: Connection reset by peer]