ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
<MajorLag> Should I just post it to #534?
<MajorLag> Well, this toy game engine I've been playing with, I've had some ideas on it, it might become a real game. Albeit a relatively small one. Not sure it'll be big enough to really flex Zig.
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
hopppetosse has quit [Ping timeout: 240 seconds]
arBmind has quit [Quit: Leaving.]
cenomla has quit [Quit: cenomla]
steveno_ has joined #zig
steveno_ has quit [Client Quit]
isd has quit [Quit: Leaving.]
<MajorLag> andrewrk. I'm trying to find a way to allow the importer to specify, on import, if they want unicode or not (basically #define UNICODE). I want to be able to do this in a way that allows me to import both versions if I want. So far, I can only think of two ways to do this: combine all the pieces (I've got it in 7 files since win32 api is so huge) and put them inside an empty struct returned by a function, or dupli
<MajorLag> ckages. Is there a better way I'm not thinking of? Maybe this isn't a thing I should be doing in the first place...
<jacobdufault> Any thoughts on custom formatters for format strings?
<jacobdufault> ie, customizing what my_obj renders to in fmt("{}", my_obj)
<andrewrk> MajorLag, I think you could make a function that runs at compile time and does the @cImport that takes UNICODE as a comptime parameter
<andrewrk> if it doesn't work I'll fix whatever issues come up
<MajorLag> andrewrk, it isn't C. It's all Zig.
<andrewrk> ahhh
<MajorLag> though something as straightforward as a C include would solve the problem.
<andrewrk> is this the windows A vs W thing?
<andrewrk> if so, I suggest following the pattern in std.os.windows. Don't try to do the thing microsoft does where you "select" which API you want. Just expose all the versions of the functions directly, and explicitly put the A or W every time.
<MajorLag> yeah. I think I'm just trying to hard, I don't even think there's a use case for importing both versions since relatively few constants would actually change, most of which are just aliases of const_A or const_W depending on UNICODE. The few that aren't... about 100, I could just separate into A and W versions.
<MajorLag> Yeah, I probably shouldn't have rabbit holed down this path, it seems silly in retrospect.
<andrewrk> for what it's worth, according to my research, the most reliable thing is to always use the W versions
<andrewrk> unfortunately, since in nearly every other context, you want utf-8 encoded strings, this involves a decode from utf8, encode to UTF-16LE, call windows API, decode from UTF-16LE, encode to UTF-8
<andrewrk> jacobdufault, yes, I think we need a couple more reflection builtin functions, and then std.fmt.format can check if a given struct has a method with a particular name, and call it when formatting
<MajorLag> Fortunately converting between utf8 and utf16 isn't that bad. Well, unless one or the other is using codepoints they aren't supposed to.
<andrewrk> that can either be an assertion failure or an error code depending on what makes sense for the API. probably an error code. you can always assert that an error is not a particular error code later.
<andrewrk> jacobdufault, thank you for your donation :)
<MajorLag> The comptime version I made throws a compileError. If I wrote a runtime version I'd throw an !error... except that supposedly Windows will allow invalid codepoints to be encoded in, for instance, filenames. So there's that to deal with at some point.
<andrewrk> another strategy is to have your encoding/decoding function return an error code, and use `catch unreachable` at compile time
<andrewrk> then you can use the same code for runtime and comptime
<MajorLag> I'd also have to take an allocator at runtime, which isn't necessary at comptime.
<andrewrk> fair enough. I do have some plans to make that a little more seamless between comptime and runtime
SimonNa has joined #zig
<jacobdufault> andrewrk: :), zig is one of the most interesting languages I've seen, I think even more so than jai. I hope it does well
cenomla has joined #zig
<GitHub79> [zig] jacobdufault opened pull request #814: Make Utf8View public, add comments, and make iterator lowercase. (master...utf8-view) https://git.io/vA5Yp
davr0s has joined #zig
<GitHub18> [zig] andrewrk pushed 2 new commits to master: https://git.io/vA5sT
<GitHub18> zig/master 8fd7e91 Jacob Dufault: Make Utf8View public, add comments, and make iterator lowercase.
<GitHub18> zig/master d34d366 Andrew Kelley: Merge pull request #814 from jacobdufault/utf8-view...
<GitHub79> [zig] andrewrk closed pull request #814: Make Utf8View public, add comments, and make iterator lowercase. (master...utf8-view) https://git.io/vA5Yp
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
cenomla has quit [Quit: cenomla]
Hejsil has joined #zig
<Hejsil> andrewrk, zig build randomizer 1.15s user 0.13s system 99% cpu 1.283 total
<Hejsil> Here is your > 1 second project :)
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<Hejsil> Now that I look into it, a project with a build.zig compiles a lot slower, and that's probably why the randomizer compiles in over 1s
<Hejsil> zig build-exe test.zig 0.30s user 0.03s system 96% cpu 0.341 total
<Hejsil> zig build 1.10s user 0.09s system 98% cpu 1.202 total
hoppetosse has joined #zig
hopppetosse has joined #zig
hoppetosse has quit [Ping timeout: 255 seconds]
zesterer has joined #zig
zesterer has quit [Client Quit]
zesterer has joined #zig
<GitHub153> [zig] Hejsil opened pull request #815: Translate C now handles bools better (master...more-translate-c) https://git.io/vA5o5
zesterer has quit [Ping timeout: 240 seconds]
hopppetosse has quit [Ping timeout: 260 seconds]
arBmind has joined #zig
davr0s has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
steveno_ has joined #zig
hopppetosse has joined #zig
<hopppetosse> are there any known issues with translate-c and structs/functions involving floats? It seems it fails to emit code in these cases
davr0s has joined #zig
Hejsil has quit [Quit: Page closed]
<MajorLag> I haven't noticed any issues with it emitting floats in structs or functions. I did have an issue where float literals were 0.000000 when the C source used scientific notation.
Hejsil has joined #zig
<GitHub92> [zig] andrewrk pushed 1 new commit to master: https://git.io/vAdkL
<GitHub92> zig/master c3807df Andrew Kelley: remove value judgement from std lib API docs...
<GitHub169> [zig] andrewrk closed pull request #815: Translate C now handles bools better (master...more-translate-c) https://git.io/vA5o5
<GitHub193> [zig] andrewrk pushed 6 new commits to master: https://git.io/vAdk2
<GitHub193> zig/master bf47cf4 Jimmi Holst Christensen: expr to bool is now it's own function....
<GitHub193> zig/master 61ecc48 Jimmi Holst Christensen: Added appropriate TODO comment to UO_LNot
<GitHub193> zig/master ed1386e Jimmi Holst Christensen: Simple translation of UO_LNot
davr0s has quit [Ping timeout: 248 seconds]
<hopppetosse> MajorLag: I still haven't been able to replicate the issue in a simple example, but I've narrowed it down to being caused by floats
<hopppetosse> I'm on a release build of zig on windows, I'll try it on a vm later
davr0s has joined #zig
<andrewrk> Hejsil, that's a good point, I'll start by caching the build script
<Hejsil> Nice!
<andrewrk> we can also cache builtin.o and compiler_rt.o
<andrewrk> those are the no-brainers
<andrewrk> then comes the more interesting work of turning a compilation into a job queue and separating a build into the best number of .o files for compilation performance
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<MajorLag> For anyone using it, that UTF8TO16 comptime function I posted yesterday has a glaring flaw (because I didn't test very thuroughly it of course), you need to unwrap the results of utf8DecodeX
<MajorLag> ..it also doesn't take C strings, which is the intended use case for me so I botched it pretty good.
hopppetosse has quit [Ping timeout: 245 seconds]
<MajorLag> andrewrk: I honestly did not expect that returning &const u8 from a stack allocated [N]u8 in a comptime function would work. That's great.
isd has joined #zig
davr0s has joined #zig
Hejsil has quit [Read error: Connection reset by peer]
<andrewrk> MajorLag, that's intentional, so you can rely on it :)
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
<MajorLag> That's great because otherwise I wasn't sure what I was going to do about comptime C wide string literals. For non-c literals, though, [N]u8 goes in, []const u8 comes out. Only problem with that is if I'm passing the result to C I have to remember to pass a ptr to [0].
<andrewrk> I think the pointer reform issue is going to help with this
<MajorLag> I agree. I think a lot of things will be better.
isd has quit [Quit: Leaving.]
Ichorio has joined #zig
arBmind has quit [Quit: Leaving.]
isd has joined #zig
isd has quit [Ping timeout: 240 seconds]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
isd has joined #zig
cenomla has joined #zig
<MajorLag> andrewrk: in order to test that all these win32 constants resolve, I crated a powershell script to create a zig file that runs a test by printing out each constant's value. Is there a better way? A flag to the compiler that says "I know I didn't actually use this, but could you make sure it resolves anyway?"
<andrewrk> MajorLag, ah, yeah, this problem
<andrewrk> here's something to consider: how would this work for generic functions?
<andrewrk> also, how would this work for functions which are only called in a comptime if, e.g. a windows utility function when building on linux?
<andrewrk> this is going to be relevant for IDEs
<andrewrk> maybe the best thing is to introduce this --check-all-declarations flag, but you may get compile errors, and that's just understood
isd has quit [Ping timeout: 255 seconds]
<MajorLag> yeah, I dunno. I didn't really put much though into it beyond the 20k or so constants I have in front of me
<andrewrk> MajorLag, why not leave em, and deal with the possible errors later?
<MajorLag> I probably should, but on the other hand most of these are easily fixable with some regex search/replace.
davr0s has joined #zig
<andrewrk> I'll add that --check-all-declarations cli option. we can leave it as a kind of experimental tool
<GitHub16> [zig] andrewrk pushed 1 new commit to master: https://git.io/vAdNK
<GitHub16> zig/master 07e47c0 Andrew Kelley: ptrCast builtin now gives an error for removing const qualifier...
<GitHub9> [zig] andrewrk pushed 1 new commit to master: https://git.io/vAdAZ
<GitHub9> zig/master 5d58200 Andrew Kelley: fix broken tests from previous commit
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
<GitHub154> [zig] andrewrk pushed 1 new commit to master: https://git.io/vAdpv
<GitHub154> zig/master cc0f660 Andrew Kelley: unless hf is specified in target environ, assume soft floating point...
zesterer has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
zesterer has quit [Quit: zesterer]
cenomla has quit [Quit: cenomla]
cenomla has joined #zig
Ichorio has quit [Ping timeout: 240 seconds]
cenomla has quit [Client Quit]
cenomla has joined #zig
zesterer has joined #zig
<GitHub124> [zig] andrewrk pushed 1 new commit to master: https://git.io/vAdj3
<GitHub124> zig/master 44ae891 Andrew Kelley: fix assertion when taking slice of zero-length array...
zesterer has quit [Quit: zesterer]
hoppetosse has joined #zig
zesterer has joined #zig
davr0s has joined #zig
<GitHub61> [zig] andrewrk pushed 1 new commit to master: https://git.io/vAFIO
<GitHub61> zig/master eff3530 Andrew Kelley: var is no longer a pseudo-type, it is syntax...
cenomla has quit [Quit: cenomla]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
jdufault has joined #zig
hoppetosse has quit [Ping timeout: 240 seconds]