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/
clktmr has quit [Ping timeout: 246 seconds]
<andrewrk> waleee-cl, pixelherodev: the IRS allows sending this form (https://yukari.sr.ht/internet-society-form-13909.pdf) via email, so I will fill it out and do that
<andrewrk> and then I'll hope that other, more powerful non-profit entities band together to defend .org
return0e_ has joined #zig
return0e_ has quit [Client Quit]
<daurnimator> andrewrk: that comment is the stream branch. master and the random branch are in a previous comoment.
protty has quit [Ping timeout: 260 seconds]
<andrewrk> daurnimator, so where is the measurement for the std lib binary with master branch?
<andrewrk> it would help if you documented the commands you ran
mahmudov has quit [Remote host closed the connection]
<daurnimator> and I'm running `./build/zig test --override-lib-dir lib lib/std/std.zig` sometimes with a --release-fast added
<andrewrk> daurnimator, that comment says "testing lib/std/rand.zig" which is not all the std lib tests, with both streams and rand mixins. does it make sense what I'm asking for?
<daurnimator> andrewrk: that's the first half of the comment. the second half is: > Testing just lib/std/std.zig for now:
<andrewrk> can you just make it clear? it's not clear
<daurnimator> andrewrk: I've edited the most recent comment to hopefully make it clearer
protty has joined #zig
lunamn has quit [Quit: leaving]
<stratact> Did anyone in the Zig community write a terminal emulator?
return0e has quit [Ping timeout: 250 seconds]
return0e has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
<daurnimator> comment edited again to turn it into a table :)
<andrewrk> daurnimator, thanks, that is crystal clear :)
<daurnimator> protty: reset_event.test "std.ResetEvent"...reached unreachable code
<protty> uh oh. What are the system details?
<daurnimator> protty: running the test again it succeded... haven't been able to trigger the failure a second time
<daurnimator> protty: cpu: i7-8550U os: linux
<protty> may be due to slower os scheduling on a receiver wait: https://github.com/ziglang/zig/blob/master/lib/std/reset_event.zig#L400 didn't want the test to block but also wanted to see if setting & resetting multiple times worked across threads. That ping pong style is usually not its use-case to begin with so would it be OK to replace it with a simpler
<protty> oneshot test?
<pixelherodev> Alrighty, tests passing on OS layer :)
ky0ko has quit [Remote host closed the connection]
<Snektron> Hey i didnt know you could usingnamespace like that
<Snektron> Interesting...
<pixelherodev> like what?
<Snektron> Inside a struct, like daurnimator's mixins
<pixelherodev> ah
<pixelherodev> Well, I mean, you can do it in an @import ed file, which is effectively a struct
<pixelherodev> So it does make senser
<pixelherodev> s/senser/sense
<Snektron> It occurs to me that i wrote asome mat/vec stuff in c++ which works basically like that
<Snektron> Except that it feels quite hacky
<Snektron> A Vec is declared as `template <typename T size_t N> struct Vec : BaseVec<T, N>`
<Snektron> BaseVec is specialized for size to make you able to subscript on x, y and z
<Snektron> Can those mixins hold state? If so, you could implement the same in Zig:
lqd has quit [Quit: Connection closed for inactivity]
<Snektron> pub usingnamespace if (Size == 2) XYStorage(Self) else if (Size == 3) XYZStorage else @CompileError("oof");
<daurnimator> Snektron: no. usingnamespace only imports methods; not fields
<Snektron> I see
<Snektron> Does it import constants?
<Snektron> I suppose the way to implement it would then turn around, which is actually OK i suppose
<Snektron> I cant remember why i didnt engineer it like that with CRTP
<Snektron> Anyway, good to know you can do this
ky0ko has joined #zig
tgschultz has quit [Ping timeout: 265 seconds]
muffindrake has quit [Ping timeout: 246 seconds]
muffindrake has joined #zig
protty has quit [Remote host closed the connection]
<daurnimator> pixelherodev: I just realised I've been reading your name wrong this whole time. I've been seeing "pixel-here-to-dev"
<pixelherodev> heh
<pixelherodev> Don't even ask me where my virtuonym came from
<pixelherodev> It was a few years back and I've been using it since, having to explain to people "No I didn't know pixelhero was a real game, no I'm not its developer" :P
kapil_ has joined #zig
emekankurumeh[m] has joined #zig
<emekankurumeh[m]> would it be possible to add commands to the zig compiler as plugins? similar to git or rust's cargo
<daurnimator> emekankurumeh[m]: like what?
<emekankurumeh[m]> i.e. some executable named zig-cmdname that can be invoked zig cmdname
<daurnimator> emekankurumeh[m]: I know what you meant. but whats an example command you'd add?
_whitelogger has joined #zig
<emekankurumeh[m]> perhaps a `bloat` command similar to cargo bloat or bloaty?
hio has joined #zig
<pixelherodev> daurnimator, thanks for the feedback, working on it shortly
LargeEpsilon has joined #zig
cncl has joined #zig
squeek502_ has quit [Ping timeout: 276 seconds]
ky0ko has quit [Remote host closed the connection]
<mq32> hey
<mq32> there is no way to enforce zig fmt to insert a blank line between a comment and a statement, right?
kapil_ has quit [Quit: Connection closed for inactivity]
return0e_ has joined #zig
<cncl> is there no way to use zig on mac os 10.12? it's fine if there's not. i'm just checking to make sure that's the case
<cncl> (the only mac hardware i own cannot run 10.13 and later correctly)
<bgiannan> cncl, Sierra is not supported
<daurnimator> cncl: there is not without making modifications yourself: we drop support for an operating system as soon as all vendors do
<cncl> makes sense
<daurnimator> cncl: apple dropped support for sierra when they released catalina
<cncl> yeah, i know. it has been a problem for me. i have a specific rare model of 2013 macbook pro that apple does not support correctly
<cncl> (i have to run 10.14 in a VM just so i can run apple's dumb "notarization" tool on my software)
<cncl> i don't expect people to support it. just making sure it was an actual intentional thing, and not merely because that's what the build machine was running
<cncl> (and therefore i could build myself. but that doesn't seem to be the case. which is fine)
<mikdusan> back in April I was building on 10.11 - can't remember if it was with custom clang or not. but it was building.
lqd has joined #zig
<daurnimator> cncl: https://github.com/ziglang/zig/issues/3335 is the first issue you'd hit
<cncl> yeah, that is indeed the first thing i hit
<cncl> (i don't use macOS full time. usually i use windows.)
kapil_ has joined #zig
waleee-cl has joined #zig
<daurnimator> error: expected type 'usize', found 'i30' note: unsigned 64-bit int cannot represent all possible unsigned 30-bit values
<daurnimator> something not right with that error message...
<daurnimator> huh.... "incompatible types: 'u32' and 'i30'" (I'm trying to add them)
<daurnimator> how do I get around it?
<daurnimator> I know that the value of the u32 is at least the i30
<daurnimator> e.g. @as(u32, 50) + @as(i30, -20)
<Snektron> That reminds me: should implicit casting to usize be illegal?
<Snektron> Since the size can vary depending on platform, code might compile on one and not on the other
<Snektron> Its an easy mistake to make
<Snektron> Or is that compile error good enough
tgschultz has joined #zig
doublex_ has quit [Ping timeout: 268 seconds]
soulofdeveloper has joined #zig
doublex_ has joined #zig
<mq32> Snektron: i think a compile error should be enough
soulofdeveloper has quit [Quit: Leaving]
<fengb> daurnimator: I had a similar problem. Seems like underflow is ambiguous so there’s no elegant autocast
nooga has joined #zig
<nooga> hi, is there a good source of examples writtten in Zig? I'm trying my best with the docs, zig source and std reference but it seems like there's almost no basic examples
<fengb> I got away with @as(u16) +% @bitCast(u16, @intCast(i16)) because I didn’t care about overflows at all
<bgiannan> nooga, did you have a look at https://github.com/ziglang/zig/wiki/Community-Projects
<nooga> bgiannan: that's helpful thx!
<nooga> I'm trying to catch error.EndOfStream from io.readLine but can't figure out how to do it without listing all errors readLine throws in the switch
<nooga> I would like to break a loop in case of EOL
<daurnimator> nooga: `else => |err|`
<andrewrk> a common idiom in zig is: else => |err| switch (err) {
<andrewrk> hmm looks like the docs for switch is missing the part that shows how to obtain an error set subset by handling some errors
<andrewrk> nooga, you can shorten that if you like to: error.EndOfStream => break,
dimenus has joined #zig
<nooga> thx andrewrk
leeward has joined #zig
<leeward> I'm a little confused about unions in Zig. I have a bit field (status register in a processor) and sometimes I want to treat it as a byte but others I want the packed struct of u1 representation. Do I have to use @ptrCast to be able to bounce between these different uses at will?
<fengb> You probably want a packed union
<leeward> It seems like packed extern unions ought to have the memory layout I want, but I need to set it as a byte and then read it as a struct, and from what I can tell, Zig thinks that's an error.
<fengb> Normal unions have undefined memory representation and safety checks to prevent “off” access, while packed unions have fixed memory
<fengb> extern union is C ABI compatible unions so that could work too
<leeward> Oh, so packed unions don't guarantee that they're only represented one way at a time?
<fengb> But C unions are a bit wonky if you’re looking for guaranteed memory representation
<andrewrk> todo: clarify that packed unions allow aliasing / type punning in https://ziglang.org/documentation/master/#packed-union
<fengb> Packed have guaranteed memory. So something like packed union { u8, struct { u4, u4 } } lets you access either field correctly, provided you account for endianness
<leeward> Well let's hope my system's not nibble-swapped.
<leeward> Good to know though, thanks. I thought I had tried using packed unions and gotten an error, but I'll try it again.
<fengb> It’s always consistent on the same system. It’s just not necessarily portable if you transfer the data
<leeward> Oh, fengb, should (need) that struct be packed?
<andrewrk> I don't think test coverage for packed unions is great currently
<fengb> Oh yeah that should be packed. Everything should be packed
<leeward> ok, good
<fengb> I think packed unions don’t check that well...
<andrewrk> fengb, planning to relax that restriction btw with https://github.com/ziglang/zig/issues/3133
<andrewrk> this will allow packed structs to have arbitrary alignment, and have fields which have non-well-defined-memory-layout
<fengb> Oh neat. Will there be a way to force well-defined memory?
<andrewrk> well, yes by using well-defined memory types only
<andrewrk> it's not a breaking change
<leeward> Yep, seems to work now.
<andrewrk> hmmmm, another idea I just had. (normal, non-packed) structs could allow setting the alignment of a field to 0. this would allow zig to bit-pack the field
<fengb> I mean a keyword or something. I often do stupid stuff like forget a packed
<andrewrk> ahh I see, you want a compile error on an accident. yes that should definitely be possible
<fengb> And right now the compiler tells me I’m dumb. But with this change I’m afraid it’ll lead to a wild goose chase
<fengb> Yep
<andrewrk> this align 0 field thing is a big deal, this could be a really good idea
<fengb> Ah making normal structs packable could be a good semantic solution
<andrewrk> you want to save memory? find some fields that you can afford to do bit shifts to access, and mark them align(0)
<leeward> Would packed then just be sugar for align(0) on all the fields?
<andrewrk> leeward, nearly - it also enforces order, and that zig won't put extra (safety-related) fields
<leeward> Oh, so align(0) would let the compiler pack the struct for optimal density but keep it a zig struct?
<andrewrk> yes
<leeward> Interesting.
<leeward> That means no pointers to align(0) fields though, right?
<andrewrk> right, pointers gain some bit offset metadata which don't cast into normal pointers
<andrewrk> but the pointers work otherwise. you just wouldn't be able to store them in a field or as a funcion parameter type
<leeward> That does make them a bit less useful.
<leeward> I'm not sure why I'd want a pointer to a field in a struct if I didn't want to pass it to a function.
<leeward> Still, I see why you wouldn't want to interact with the ABI.
<mq32> andrewrk: do you know the way C# handles "packed structs"? you can not only specify alignment, but also "field offset" which allows for some pretty neat constructs and some nice explicit layouting
<andrewrk> mq32, that's neat. the closest zig can offer to that is packed structs + comptime asserts
<mq32> yeah
<mq32> what is fun about that feature is that it isn't safety-checked
<andrewrk> for the align(0) fields thing though- consider this use case: flags
<mq32> someone once told me: you cannot do unions in c#. i told him: hold my beer! :D
<mq32> it allows you to overlap fields ^^
<andrewrk> you could have 8 bools in a struct all marked align(0), and zig would be allowed to put them all in a u8
<mq32> but the align(0) idea is great!
<mq32> +2 from my side :D
<andrewrk> and you rarely need a pointer to a flag, you're usually checking them from a base pointer
<andrewrk> actually, people have been asking how to do flags in zig forever, and this is the best way
<leeward> It's definitely a good idea. As long as it spits out sensible errors when people inevitably try to take pointers to fields that have been align(0)'d.
<leeward> If you pack a struct of 8 bools now, does it fit in a u8?
<andrewrk> yes
<mq32> https://ideone.com/WyDE8w <= this is wonderful :D
<andrewrk> the error currently looks like this: https://clbin.com/5ttG1
<leeward> Not the most informative error ever, but that's the kind of thing that can be nailed down after the language stabilizes a bit.
<leeward> mq32, You have a very strange definition of wonderful.
<mq32> leeward: it's actually really helpful!
<mq32> you can interface really well with C in C#
<leeward> mq32: Yeah, if there's no union in C# I can see how it would be necessary. Still an ugly hack.
<mq32> yeah, kinda :D
<mq32> but: you can enforce arbitrary struct layout which is nice
<leeward> I've never used C#. I wrote the first Windows software of my career last week, and it was in Python.
<mq32> C# is quite nice actually
<mq32> it's my preferred "high level" language
<leeward> I hear good things, I just never really interact with the Microsoft ecosystem so it's been at the bottom of my to-learn list for a long time.
<mq32> i'm not a fan of dotnet core though
<mq32> it's hyped a lot, but i think they are throwing away a lot of good stuff with that
<leeward> I did a code review for some C# code once and it seemed very boilerplate-y. That could have been the author though. It wasn't clear if C# was missing metaclasses or the stuff was just written strangely, but there were a lot of classes that were nearly identical.
<mq32> i would like to use .net for some apps at work, but we have one "hard" restriction:
<mq32> if you cannot make a one-file-application with your programming language/framework/..., don't use that for non-inhouse apps
<mq32> and it's hard with .NET/Windows Forms already not to use *any* external libraries
<mq32> but with dotnet core, you have to ship the whole "dotnet" you use with your app
<leeward> There's no way to bundle the runtime in a single executable? Python can do that.
<mq32> the runtime is installed in windows
<mq32> but not libraries
<leeward> weird
<mq32> i found a way though :D
<mq32> you can make the libraries embedded resources you "preload"
<mq32> it works, but it's a hacky workaround
<leeward> The last thing I wrote production for-customer code on at work was an msp430. C is the high level language of choice there.
<andrewrk> zig has msp430 arch support
<mq32> i read some 8051 code the last days
<leeward> It's not tier 1 though, is it?
<mq32> i don't think zig has 8051 code support... :D
<leeward> I thought it was experimental in llvm.
<leeward> or tier 2, for that matter
<andrewrk> msp430 is marked tier 4
<leeward> Also, I don't think Zig is ready to be approved for use in medical devices. Not that I wouldn't love to.
<andrewrk> that's certainly true
return0e has quit [Read error: Connection reset by peer]
return0e has joined #zig
Akuli has joined #zig
dimenus has quit [Remote host closed the connection]
return0e_ has quit []
<leeward> It would actually be pretty cool if we could get the compiler 62304 conformant at some point, but it's such a burden that it'd probably have to be a pretty high-stability fork. Certainly too much overhead for while the language is still evolving rapidly.
<leeward> Though I don't know if it's a thing that can be be bolted on after the fact.
<leeward> It's also the kind of thing people are actually willing to pay for; certified compilers get expensive.
<stratact> what happened to `[..]` slicing?
LargeEpsilon has quit [Ping timeout: 246 seconds]
<stratact> Ah nevermind, it looks like using []const u8 for string literals is the better practice.
<andrewrk> stratact, if you want to convert a string literal to an array (like it was before) you can put .* on there
<stratact> andrewrk: I tried that as well, but it didn't work.
<stratact> although I probably made a mistake somewhere
<andrewrk> it works and it is covered by tests. provide a pastebin if you want help figuring it out
<stratact> Understood and no worries. I got it to compile with []const u8 after messing around, I just need to break outdated habits. I also need to get my programming rhythm back.
<stratact> Sigh, I spent most of my time yesterday waiting for a friend to backport patches from st to his C terminal emulator project, so I could port it to Zig and enhance it from there but it took too long. So I'm doing another project in the mean time ;)
adamkowalski has joined #zig
<adamkowalski> Happy Thanksgiving, hope it was a good one
<stratact> adamkowalski: Happy Thanksgiving, however, I believe it's now Black Friday in the States :P
<stratact> although, Black Friday online sales are not that special these days :/
<leeward> Black Friday: The best day to stay in and hack.
<andrewrk> Hack Friday
<leeward> ^^
<leeward> I have a u16, and I want to interpret its low 12 bits as an i12. @bitCast(i12, num & 0xfff) is unhappy. Do I have to @ptrCast it down to a u12 then @bitcast it to signed?
<fengb> Can possibly do @truncate(i12, num)
<leeward> error: expected signed integer type, found 'u16'
<leeward> Whoops, looks like I have to leave it unsigned and use +% anyway; I'm adding it to a u12.
<andrewrk> @bitCast(i12, @truncate(u12, x))
<leeward> How is @truncate different in this case from @intCast? Should I be using @truncate in general when I want to pick the low N bits from a word?
<andrewrk> leeward, I believe this is explained here: https://ziglang.org/documentation/master/#truncate
<andrewrk> yes truncate is a good way to pick the low N bits from a word
<andrewrk> it's one of the safe casts
<fengb> Hmm should bitwise operations do auto narrowing? Or is that surprising
<leeward> So is intCast better to use if I want to assert that the value will fit in the new size?
<andrewrk> fengb, it's planned for them to give narrowing value annotations, but not change the type
<andrewrk> so you will be allowed to do, for example: var x: u16 = 0xabcd; const y = x & 0xff; var z: u8 = y;
<andrewrk> but @typeOf(x & 0xff) is still u16
<leeward> I want this. I want this very much.
<leeward> I think we talked about it earlier.
<mq32> andrewrk: that would be cool
<mq32> !
<leeward> Ugh, this compiler is not generating jumps correctly and I don't know why.
<leeward> or branches!
<leeward> Oh, I bet it's because I'm not running the linker. Silly me.
<mq32> leeward, oh yeah i did something similar this week
<mq32> i was wondering why my compiles did not work and i just ran an 1hour old executable
<leeward> Yeah, I hate it when that happens.
<andrewrk> I don't understand this due to not understanding rust semantics, but if someone here did understand it, that would be useful when we decide on zig's planned pinning feature: https://internals.rust-lang.org/t/unsoundness-in-pin/11311
<andrewrk> hm there isn't a specific proposal for it, just this comment by dbandstra: https://github.com/ziglang/zig/issues/591#issuecomment-418186046
<mq32> andrewrk, can you explain "pinning" in this context?
<andrewrk> yes, filing an issue
lunamn has joined #zig
<pixelherodev> daurnimator, re: importing os.bits, it's not importing it into the os struct, it's importing it using pubnamespace into std.os.bits, which is itself imported into std.os using pubnamespace
<pixelherodev> It's how e.g. fd_t is defined
bjorob has joined #zig
<Snektron> andrewrk: the annotations sounds similar to a thing i was thinking about
<Snektron> If every integer is annotated with its possible range of values, you could do stuff like that and also optimization maybe
<Snektron> Stuff like array bounds checking could be eliminated after a manual bounds check
<mq32> i have *just* refreshed the page and it was not there yet
<mq32> you ninja'd me!
<andrewrk> right so I'm pretty sure Rust has this feature already, but apparently it is unsound, and it would be good to understand why. The answer might have to do with Rust semantics that does not apply to zig
<mq32> i think it's something related to rust semantics
<mq32> but i'll try to think about how this could introduce problems
<mq32> but i really think this feature is nice, as it also allows you to safely store "upward references" in a graph and document that this may break
riba has joined #zig
adamkowalski has quit [Quit: Lost terminal]
riba has quit [Ping timeout: 268 seconds]
<stratact> oh, how cool, a [*]const T coerces to a [*c]const T automatically in imported c function, sweet
<stratact> Zig is becoming more joyful.
doublex_ has quit [Ping timeout: 250 seconds]
riba has joined #zig
mahmudov has joined #zig
riba has quit [Ping timeout: 276 seconds]
<leeward> I'm failing at finding the conditional compilation stuff in the docs.
<leeward> I want to do one thing when running a test and another in any other build.
<leeward> ah, `builtin.is_test`
<leeward> whine: zig build makes me unhappy on the insides. I really hope the package system makes it worth while, because right now I'd rather use Make.
<mq32> i think the biggest problem with zig build right now is the missing documentation
<leeward> It's a big problem, but yet another build system (this one apparently in the SCons model) is not what I needed.
<leeward> It's not making me decide not to use Zig, and I don't want to be a jerk about it, but I really do wonder at the decision to create it sometimes.
<leeward> Ooh, this is fun. I got a failed assertion that tells me it's a bug in the Zig compiler.
<mq32> leeward: the thing about zig build vs. make:
<mq32> i need the zig compiler anyways to build zig projects
<mq32> if i have a "raw" system and install zig, i can build projects with zig build
<mq32> but not with make
<leeward> Semantic Analysis [716/735] Assertion failed at /home/me/zig/zig-hg/src/ir.cpp:265 in const_ptr_pointee_unchecked. This is a bug in the Zig compiler.
<leeward> mq32: Because you don't have make installed?
<mq32> yep ;)
<mq32> how do you install make on windows?
<mq32> so that your Makefile actually does work
<leeward> wsl? I thought Windows people used IDEs that do all their building for them.
<mq32> well
<mq32> now we have two build systems
<mq32> msbuild and gnumake
<mq32> or we could've used zig build and have only one ;)
<leeward> I feel like this should already be a solved problem.
<mq32> it is not
<mq32> it is hell
<mq32> another build system does not hurt
<mq32> it does even hurt less if it comes for a single language with a single purpose: to build zig code
<leeward> Ok, so let's assume that the correct thing to do is to add a new build system. Why a library? Why not a program that interprets some DSL or config file to build code?
protty has joined #zig
<leeward> There's certainly precedent for that between ant, cargo, rebar, shake, etc.
<mq32> because it's simpler
<mq32> what is easier to maintain, debug and understand? a DSL, compilre for that DSL and execution layer
<mq32> or "the language you're writing your code anyways with"?
<leeward> That's the philosophy behind SCons, and...ugh.
<protty> is there a way to override the default std.event.Loop with a custom implementation?
<leeward> For as specific a domain as a build system, I'd argue the DSL.
<mq32> i dunno
<mq32> i haven't used scons
<mq32> but zig build is pretty straightforward
<mq32> also: SCons tries to do the "i can build all"
<mq32> which does not work
<leeward> Maybe this is my Make-centricity showing through, but when defining a build system, you're basically just building a DAG and telling it how to combine each of the nodes to make their parents.
<leeward> The impression I got was that zig build was supposed to be an all-purpose build system for whatever you want.
<mq32> nah
<leeward> Maybe I misinterpreted something.
<mq32> zig build is "invoke the zig compiler with fancy parameters instead of CLI"
<mq32> you can configure "zig build-exe"-invocations and so on
<leeward> The docs talk about building C/C++ code with it, though that sentence is about 1/3 of the docs.
<mq32> also you can add arbitrary build commands
<mq32> yeah, sure
<mq32> you can also build C/C++ with zig
<mq32> "zig build" is just a replacement for shell scripts invoking the compiler
<mq32> it does not do dependency tracking for source files or similar
<mq32> (at least not to my understanding)
<leeward> Maybe something I read that suggested that led me to extend it beyond C and C++ in my head.
<leeward> It seems like it's got some dependency-tracking magic in it to me.
<leeward> Granted, I have a very bad understanding of it, and my mental model is probably very wrong.
bjorob has quit [Ping timeout: 265 seconds]
<mq32> leeward: yeah you can depend build steps on each other
<leeward> I have a small build.zig file and when I `zig build test` it runs tests in files not named in my zig.build.
<mq32> like "when executing zig build run, make sure that *exe1* is actually built before"
<leeward> er, build.zig
<mq32> huh
<mq32> zig build test fails for me if not having a "test command" in my build file
<mq32> [felix@denkplatte-v2 tmp]$ zig build test
<mq32> Cannot run step 'test' because it does not exist
<mq32> default build.zig generates ths
<leeward> So I have main.zig with a test that just imports ops.zig. In ops.zig, which depends on decode.zig, I have a whole slew of tests. I also have tests in decode.zig. My build.zig has an addTest("src/main.zig") but doesn't mention any of these other files.
<leeward> The fact that there's a "test" target is explicit, but the dependencies for it seem to be getting generated automagically.
adamkowalski has joined #zig
<mq32> that has nothing to do with zig build
<mq32> just run "zig test src/main.zig" and see what happens ;)
<mq32> zig will run all tests in your code graph that is from your current "package"
<leeward> I think we're agreed that zig build would benefit from some good docs.
<leeward> Ok, well that's good to know.
<mq32> and what happens when you od "addTest(…)"
<adamkowalski> If anybody uses vim and vim-test I have been working on integrating zig test for the past few days. Check out my fork here: https://github.com/adam-r-kowalski/vim-test
<mq32> you add an invocation with "zig test …" to your build jobs
bjorob has joined #zig
<adamkowalski> It supports test file, test nearest, test last, and test visit
<adamkowalski> I would appreciate anybody who can help test it out and help me improve it. Once we know it works on a few different machines I would like to submit a pr to get zig support into vim-test proper
<leeward> I think instead of whining about build systems, I should ask the question that led me to it. I've got some test data that I want to feed to my program, but it's generated (by make, since the test data is object code) and I want to rope it in with my `zig build test`. Though from what I'm learning, maybe the right thing to do is to wrap this whole thing up in a Makefile.
<mq32> leeward, how do you compile your zig executable with "make" then?
<mq32> all it should do is probably this:
<leeward> I don't. I've been trying to use zig build.
<mq32> zig-cache/bin/myExecutable: src/main.zig
<mq32> zig build-exe $<
<mq32> yeah i have to admit that i am also using a makefile for that :D
<mq32> but: i'm compiling the generator with another language, so i need another build system anyways ¯\_(ツ)_/¯
<leeward> Ok, so I won't be shunned for adding a Makefile around my stuff. Good to know.
<leeward> Yeah, the test data is compiled from either C or assembler or C++ with a non-llvm compiler.
<mq32> i think the way with zig build is: builder.addSystemCommand(…)
<leeward> I'm getting to the point in my emulator where it can execute programs, which is exciting, and I can use the programs as tests.
<leeward> I should probably put it up somewhere, but bitbucket's ditching us poor mercurial users.
<mq32> btw, here's an example for zig build with a custom command
<torque> sourcehut has mercurial support, but I don't know what else still does
Akuli has quit [Quit: Leaving]
<leeward> sourcehut...hadn't heard of it
<euantor> hg.sr.ht - definitely worth trying out and their builds system is great
<leeward> I'll probably just use hg-git and put it on github. Sigh.
<leeward> mq32: Thanks. I might use that.
<mq32> yeah, me too
<mq32> i'll take a look at the source code some more
<leeward> euantor, I suppose I'll go generate a new password. I do have a bunch of projects that need moving from bitbucket.
<euantor> There’s a tool to import from bitbucket too
<leeward> fancy
<leeward> Is this like a federated github?
<euantor> And a fairly active IRC channel at #sr.ht
<euantor> It’s more like an open source GitHub, CI, mailing list, wiki system
<euantor> Eg: the source for the Git service is at https://git.sr.ht/~sircmpwn/git.sr.ht
<pixelherodev> Pretty sure Zig uses sr.ht for the FreeBSD CI
kapil_ has quit [Quit: Connection closed for inactivity]
<andrewrk> strap your jetpacks on for this proposal: https://github.com/ziglang/zig/issues/3806
<leeward> looks useful
<leeward> I think I found a compiler bug.
<protty> zig's approaching dependent-typing territory
<leeward> when I run "zig build run" it hits an assertion.
<leeward> "zig build test" still succeeds though.
<leeward> zig/src/ir.cpp:265 in const_ptr_pointee_unchecked.
<leeward> mmm, just realized what the first question was; updating and rebuilding zig
waleee-cl has quit [Quit: Connection closed for inactivity]
<leeward> Same error.
<andrewrk> protty, according to wikipedia, we're already there
<andrewrk> "In computer science and logic, a dependent type is a type whose definition depends on a value." sentinel-terminated pointers, functions that take a comptime usize and return a type
<leeward> protty, Zig already has dependent types: fn Thing(n: u1) type { return switch(n) { 0 => struct { a: u1 }, 1 => struct { a: u2 }, }; }
<protty> oh yea, forgot values could be comptime
<protty> this is wack
leeward has quit [Quit: Leaving]
wootehfoot has joined #zig
<pixelherodev> I like that proposal
<pixelherodev> And the linked ones :)
<pixelherodev> On a completely unrelated note, requiring the hard compiler RAM limit to be 4GB seems too high to me, especially given that the majority of computers today are at least quad-core
<pixelherodev> If doing pararellized compilation, that would require e.g. 16GB of RAM, which is probably a few years away from being the norm
<pixelherodev> s/pararellized/parallelized
<pixelherodev> One concern re: that proposal: `There are 3 possible values of this type, so Zig chooses to use u2 for the tag type. It will require 1 byte to represent it, wasting 6 bits. If you wrap it in an optional, that will be 16 bits to represent something that, according to information theory, requires only 2 bits. `
<pixelherodev> Shouldn't that be 3 bits?
<pixelherodev> Oh wait, never mind - null would effectively be a fourth enum value, not requiring a bit of its own - duh