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/
hio has quit [Quit: Connection closed for inactivity]
fu5ha_ has joined #zig
walac has quit [Ping timeout: 258 seconds]
st4ll1 has quit [Ping timeout: 245 seconds]
strmpnk has quit [Ping timeout: 258 seconds]
walac has joined #zig
strmpnk has joined #zig
fu5ha_ has quit [Read error: Connection reset by peer]
fu5ha_ has joined #zig
fu5ha_ has quit [Remote host closed the connection]
marijnfs has joined #zig
marijnfs__ has quit [Ping timeout: 248 seconds]
<gamester> Tetralux: "But it _is_ inconsistent" - for this to make any sense there'd have to be syntax to dereference the slices. x[0..n].* = y[0..n].* - without an explicit dereference you're making things _absurdly_ inconsistent. "To me a slice is nothing more than a view into an array" ok then a pointer must be a view to a single element and therefore ptr = ptr2 should write what's in ptr2 to ptr, or at least &data = &data2 would do that. Otherwise it
<gamester> would be inconsistent with your slicing idea. At this point you've lost the ability to write to slices and pointers.
<gamester> write to / reassign
<gamester> So "x[0..n] = expr" would modify the array x but "var slice = x[0..n]; slice = expr" would modify the slice. Huge inconsistency.
fu5ha_ has joined #zig
IntoxicatedHippo has joined #zig
Tetralux has quit [Quit: Leaving]
curtisf has quit [Remote host closed the connection]
fu5ha_ has quit [Remote host closed the connection]
st4ll1 has joined #zig
IntoxicatedHippo has quit [Ping timeout: 258 seconds]
neceve has joined #zig
iamthad has joined #zig
affinespaces_ has joined #zig
dembones has joined #zig
rxF has joined #zig
ZombieByte has joined #zig
xcko has quit [*.net *.split]
THFKA4 has quit [*.net *.split]
dembones_ has quit [*.net *.split]
affinespaces has quit [*.net *.split]
torque has quit [*.net *.split]
iamthad_ has quit [*.net *.split]
jelleke has quit [*.net *.split]
bodie_ has quit [*.net *.split]
affinespaces_ is now known as affinespaces
jelleke has joined #zig
hio has joined #zig
IntoxicatedHippo has joined #zig
ltriant has quit [Quit: leaving]
fu5ha has quit [Read error: Connection reset by peer]
rxF is now known as torque
fu5ha has joined #zig
fu5ha has quit [Remote host closed the connection]
fu5ha has joined #zig
fu5ha has quit [Remote host closed the connection]
fu5ha has joined #zig
fu5ha has quit [Remote host closed the connection]
fu5ha has joined #zig
fu5ha has quit [Remote host closed the connection]
fu5ha has joined #zig
fu5ha has quit [Remote host closed the connection]
fu5ha has joined #zig
fu5ha has quit [Remote host closed the connection]
fu5ha has joined #zig
fu5ha has quit [Remote host closed the connection]
fu5ha has joined #zig
fu5ha has quit [Remote host closed the connection]
fu5ha has joined #zig
fu5ha has quit [Remote host closed the connection]
fu5ha has joined #zig
fu5ha has quit [Remote host closed the connection]
<IntoxicatedHippo> Is there a way to declare a struct with something similar to a flexible array member in C?
fu5ha has joined #zig
fu5ha has quit [Ping timeout: 245 seconds]
samtebbs has joined #zig
shachaf has quit [Ping timeout: 245 seconds]
shachaf has joined #zig
fu5ha has joined #zig
marijnfs has quit [Ping timeout: 248 seconds]
marijnfs has joined #zig
fu5ha has quit [Ping timeout: 248 seconds]
xcko has joined #zig
fu5ha has joined #zig
st4ll1 has quit [Ping timeout: 245 seconds]
<tgschultz> IntoxicatedHippo: not at this time. Structs must be of fixed size.
<mq32> tgschultz, what about a function that returns an array with comptime_int size?
<tgschultz> that's very doable: `fn foo(comptime size: usize) [size]u8` would be the declaration. However, this probably won't work for the usecases of what IntoxicatedHippo is asking about because the size won't be comptime known.
<tgschultz> though of course, it could return a slice instead
bheads has joined #zig
bheads has quit [Quit: bheads]
bheads has joined #zig
dsego has joined #zig
fu5ha has quit [Ping timeout: 268 seconds]
IntoxicatedHippo has quit [Remote host closed the connection]
IntoxicatedHippo has joined #zig
dsego has quit [Quit: dsego]
fu5ha has joined #zig
Tetralux has joined #zig
halosghost has joined #zig
fu5ha has quit [Ping timeout: 248 seconds]
Akuli has joined #zig
<Tetralux> gamester: Allow me to play devils advocate a little more here: x[a] = y[a]; x[a..b] = y[a..b]; --- Seems alright to me. Ptrs can be deref'd because they're a primitive thing that the machine can deref and we're a low-level language here. Slices are not primitive to the machine, they are primitive to the language; a little more high-level.
fengb has joined #zig
<Tetralux> Also forgive me if I'm a little slow today. I literally just woke up and I feel like it xD
<Tetralux> Also hi all o/
<samtebbs> o/
fengb has quit [Remote host closed the connection]
xcko has quit [Remote host closed the connection]
xcko has joined #zig
avoidr has joined #zig
neceve has quit [Read error: Connection reset by peer]
fu5ha has joined #zig
SimonNa has quit [Remote host closed the connection]
samtebbs has quit [Quit: leaving]
laaron has joined #zig
wilsonk has quit [Ping timeout: 245 seconds]
wilsonk has joined #zig
fu5ha has quit [Ping timeout: 245 seconds]
IntoxicatedHippo has quit [Ping timeout: 245 seconds]
<daurnimator> Has anyone implemented any compression algorithms in zig yet?
<daurnimator> e.g. DEFLATE?
<daurnimator> looks like I've already found https://github.com/ziglang/zig/issues/213
fu5ha has joined #zig
<Sahnvour> Tetralux: I thought a bit more about this slice-assignation thing, and the main thing that can be problematic is that the same expression `foo[n..m]` would have a different meaning depending on its context. not sure that's a big deal, but consistency is lost on one side
<Tetralux> Wouldn't it retain it's meaning of "the elements of foo in [n, m)" regardless of whether it's being assigned to, or not?
<Tetralux> Just that lhs=assigning them, rhs=reading them.
<Tetralux> or rather rhs=a view of them
<Tetralux> You get my point.
<Tetralux> Sahnvour, forgot to @ you xD
fu5ha has quit [Remote host closed the connection]
<Sahnvour> yeah
fu5ha has joined #zig
dsego has joined #zig
fu5ha has quit [Remote host closed the connection]
<gamester> Tetralux: Are you aware that this does not read anything? const slice = x[0..n]
<Tetralux> gamester: I corrected myself.
<Tetralux> > or rather rhs=a view of them
<gamester> s/anything/the array
laaron has quit [Remote host closed the connection]
fu5ha has joined #zig
laaron has joined #zig
<Tetralux> gamester: ?
ZombieByte has quit [Ping timeout: 246 seconds]
<gamester> I was correcting myself. The array is not read from but an address needs to be gotten.
<Tetralux> gamester: I'd assume that expr copies the ptr to x, adjusts it accordingly (though in that case it doesn't have to), and compute the length.
<Tetralux> .. and stores the resulting slice into `slice`.
dewf has joined #zig
<daurnimator> Tetralux: You mean "from x"?
<daurnimator> Tetralux: notably, at no point in `const slice = x[0..n]` is the pointer dereferenced
<gamester> I do find the point about x[a] = y[a] to be interesting. Also "ptr.* = expr". In both cases the lhs looks like it reads and then we write to that temporary. But instead x[a]= and ptr.*= are like their own operators.
<daurnimator> Tetralux: Having `x[0..n]` change whether it dereferences the pointer or not based on the LHS doesn't make sense IMO.
wilsonk has quit [Ping timeout: 272 seconds]
<gamester> Off topic: "Ubuntu to provide select 32-bit packages for Ubuntu 19.10 & 20.04" - Finally the linux world learns about system packages! Wow!
<Tetralux> daurnimator: "ptr to x" = &x
<Tetralux> or no
<Tetralux> x.ptr xD
marijnfs_ has joined #zig
<gamester> This is the only syntax that makes sense to me: x[0..n].* = y[0..n].*, equivalent to x[a] = y[a] since x[a] does dereference by default. However std.mem.copy or w/e is fine.
wilsonk has joined #zig
Akuli has quit [Quit: Leaving]
<daurnimator> gamester: agreed
bheads_ has joined #zig
fu5ha has quit [Remote host closed the connection]
bheads has quit [Ping timeout: 258 seconds]
bheads_ is now known as bheads
mawaldne has joined #zig
Ichorio_ has joined #zig
MajorLag has joined #zig
tgschultz has quit [Ping timeout: 246 seconds]
MajorLag is now known as tgschultz
Sahnvour has quit [Quit: WeeChat 2.4]
Sahnvour has joined #zig
fu5ha has joined #zig
<Tetralux> I can kindof see that.
<Tetralux> gamester: forgot to @ again..
<tgschultz> daurnimator: I think someone did port a deflate and inflate, not sure if the code is up to date even if I can find it. I wrote an inflate for PNG, but I know I haven't kept that up.
vexu has joined #zig
<tgschultz> oh, I see that was linked in the issue you linked
<Tetralux> gamester: "assign through the slice" in the same way as `p.* = value` is "assign through the pointer", as it were.
bheads has quit [Quit: bheads]
Cadey has quit [Quit: WeeChat 1.9.1]
jjido has joined #zig
<daurnimator> Tetralux: you need the `.*` on both sides.
<Tetralux> Yeah, yeah. Because you want to assign through the LHS slice, the elements within the RHS slice.
<Tetralux> 'within' being the reason there.
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #zig
<mikdusan> nice. zig's 10% represents 25% to musl (assuming patreon)
<andrewrk> yeah patreon
<scientes> yeah when i was paying attention to musl in my systemd patches i got some push-back by Lennary Poettering
<scientes> andrewrk += 1 on that decision
THFKA4 has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<daurnimator> andrewrk: make sure you repost that blog post to your patreon page :)
<mmx87> andrewrk, have you considered of using Docker images for different OSes and architectures for CI? It might be a nice way to test for multiple platforms (and architectures) easily one one server.
<daurnimator> mmx87: does docker support different OSes architectures?
<mmx87> For example for NetBSD x86_64
<daurnimator> mmx87: doesn't e.g. a linux x86_64 docker host only support linux x86_64 images?
<mmx87> No, not directly. But they use Qemu.
<andrewrk> daurnimator, I don't want to spam people who already donating
<daurnimator> andrewrk: as a donator I respect that some portion of my donation is flowing through to the musl project
<andrewrk> I see
<daurnimator> andrewrk: I wouldn't consider patreon posts spammy unless they were more than once a month without good content
<andrewrk> noted
<daurnimator> and your last patreon post was feburary last year :P
<mmx87> Qemu is for hardware virtualization, it should be quite fast. But I never tried it for compiling and stuff. But it should get the job done.
<scientes> you should def. mirror release notes there at least
<scientes> patreon posts don't all have to be sponsored
<scientes> patreon/subscribestar
<daurnimator> mmx87: so what you're really suggesting is "use qemu"... nothing to do with docker at all?
<scientes> daurnimator, why would use want to use a non-native guest?
<daurnimator> scientes: to test e.g. for netbsd on our CI boxes that may only support linux/windows?
<mmx87> Hm, yeah. That's correct, but don't many CI services use Docker images? I mean you can set it up directly, nothing hinders that.
<scientes> qemu is slow and you quickly run into bugs
<scientes> daurnimator, oh just use qemu-kvm, I don't think you realize what docker is.....
<daurnimator> scientes: I very much know what docker is...
<scientes> docker is not virtualization
<scientes> and will never support virtualization
<scientes> perhaps I didn't read the scrollback
<scientes> mmx87, qemu also supports cpu virtualizations features, which is native-speed
<scientes> now that kvm was merged
<mmx87> I was just mentioning Docker images because I thought that most CI services support that.
<mmx87> Yeah, QEMU + KVM is pretty nice. You can even run Windows at quasi full speed with GPU passthrough on Linux. Though the setup isn't that easy, because it depends a a bit on your Hardware.
<scientes> > You can even run Windows at quasi full speed with GPU passthrough on Linux.
<scientes> because of the work of Wine
<scientes> that uses libwine to provide directX on OpenGL
<scientes> anyways, that is off-topic here
<mmx87> Is that really relevant? I mean it passes the whole GPU to the VM.
<mmx87> Yeah, I know.
<andrewrk> general systems programming stuff is on topic here
<mmx87> Anyways, I don't know how well the more exotic architectures are. But in general it should work fairly well, I think.
<scientes> mmx87, Power has some difficulty because it actually uses all 64-bits
<scientes> and some hardware doesn't support that
halosghost has quit [Quit: WeeChat 2.5]
Ichorio_ has quit [Ping timeout: 252 seconds]
fu5ha has quit [Remote host closed the connection]
mawaldne has quit [Ping timeout: 260 seconds]
dsego has quit [Quit: dsego]
Cadey has joined #zig
fu5ha has joined #zig
<Cadey> andrewrk: please keep doing your work with Zig. You're doing very well on it :)
<andrewrk> thanks Cadey
<andrewrk> I saw the patreon pledge :) thanks a lot
<Cadey> no problem, i wish i could spare more per month
<companion_cube> oh damn, the V-lang drama… :o
<companion_cube> (good call out, andrewrk)
<andrewrk> yeah let's try to keep it on topic in #zig though
<andrewrk> I'm proud of everybody for keeping it on topic in here over the last few days
<mikdusan> wheres zig offtopic? `#zigot` :)
<companion_cube> (sorry, I was just reading your blogpost)
<mikdusan> andrewrk: how does one go from IrInstruction.result_loc to ResultLoc ?
<andrewrk> mikdusan, ResultLoc*s are created in the gen_* pass (AST to Zig IR). They have to get "reset" by an instruction in case of inline loops.
<andrewrk> ir_resolve_result happens in analyze_* pass and that turns ResultLoc*s into IrInstruction*s
<mikdusan> ok is there an inverse direction?
<andrewrk> no
samtebbs has joined #zig
yhoyhoj has joined #zig
<yhoyhoj> Hello. Beginner question : I am not sure was is the minimal code to add for 'test.zig' example on https://ziglang.org/#toc-A-fresh-take-on-error-handling to compile . The errors are not discarded but it does not seem to be enough
<daurnimator> yhoyhoj: which example? (they're all test.zig)
<yhoyhoj> the parseInt example, the first test.zig on the Error handling section I linked
<Tetralux> if you mean, how do you run it, you run it with "zig test test.zig"
marijnfs_ has quit [Ping timeout: 245 seconds]
<yhoyhoj> Actually I found the solution. I just needed to add cases in the switch
<Tetralux> Ah, gotcha xD
<mikdusan> andrewrk: this is followup to vector alignment fix - segfault existed before fix: https://gist.github.com/mikdusan/642e780f6fc63c29dfbda1e091d63fd3
<mikdusan> any hints? :)
dewf has quit [Quit: Leaving]
<mikdusan> (frame 5 calls ir_implicit_cast with nullptr, legit?)
vexu has quit [Quit: WeeChat 2.5]
<andrewrk> mikdusan, all the args to ir_implicit_cast are non-null
<mikdusan> typo. ir_implicit_cast_with_result(..., nullptr)
<mikdusan> seems odd to me a function named with_SOMETHING and SOMETHING==nullptr
<andrewrk> that's allowed, it means that if the cast needs a result loc, it should make one (with no_result_loc() which will allocate a stack variable)
SimonNa has joined #zig
<samtebbs> quit
samtebbs has quit [Quit: leaving]
avoidr has quit [Quit: leaving]
<yhoyhoj> I don't understand why so much of the examples end with a compiler error. I mean, it does show that the language work but why not show a success instead ? It's making things unecssarily confusing. Eg. the last example of https://ziglang.org/#toc-Compile-time-reflection-and-compile-time-code-execution (as well as the thing I asked before)
<Tetralux> That particular example is meant to demonstrate that you can run code at compile time to ensure that certain conditions are met. In that case, making sure that the array contains 1234 elements.
<Tetralux> The error _is_ the point.
<Tetralux> I get what you're saying though.
<Tetralux> In that particular case, the assert is further confirming that fibonacci(6) = 1234.
<Tetralux> But it isn't, so it errors.
<Tetralux> I could have said all that clearer, but hopefully you get my point.
<andrewrk> yhoyhoj, it's also important to know what kind of mistakes the compiler can catch, it can give you a feeling of safety
<yhoyhoj> Does the failing assert make it clear that the code was executed at compile time ? You mean that if it was a successful assert with no output it won't be as clear that the code work as expected ?
<Tetralux> In that case yes
<Tetralux> Because the array length is the result of calling fibonacci.
<Tetralux> And the call is within the [] of the array type.
<Tetralux> Which must be comptime known.
<yhoyhoj> Yes I get that. And the fact that it compiles should be enough to show that comptime expressions are working ? It would be less confusing to have the comptime block confirm that the array length is the exepected result : 6 if I am not mistaken.
<yhoyhoj> (I mean 8)
<yhoyhoj> _*
<yhoyhoj> 8*
<Tetralux> Yeah, it's 8.
<Tetralux> Thing about that example is that the comptime block around it.
<Tetralux> Without that, it does the same thing... except that it's only when you run the program that you assert.
<Tetralux> But the fact you see the assert at comptime is the point of the example.
<Tetralux> -- That you _can_ check things are true without running the program.
<Tetralux> Namely if some code you write assumes an array has an even number of items, then you can ensure that without having to run it, and so avoid how in Python, you might not notice until you tried to use that code path.
<yhoyhoj> I see, if you trid to cimpile this code without you would see this error which makes it clear that the assert was executed at compile time. I understand now and it is a great feature. But the problem is that because it is used with 'zig test' that run the program automatically it is hard to see that it is really at compile time and not at runtime.
<Tetralux> Yeah, I can understand that.
<Tetralux> You can tell because the test harness says:
<Tetralux> "n/total test "name of test"...
<Tetralux> before it runs a test.
<Tetralux> In that case, it would be "1/1 test "compile-time evaluation"...
<Tetralux> I believe in that case, if a comptime assert fails, you wouldn't see any of those regardless of how many tests you had.
<Tetralux> So if you see it at all, no comptime stuff panicked. (e.g. asserted).
<Tetralux> Also, it says "error: ..."
<Tetralux> which is only shown at comptime.
<Tetralux> At runtime you'd get "reached unreachable code" <stack trace>
<Tetralux> But yeah, it could be worth considering.
<yhoyhoj> Well, so it's not too bad but I feel it could be made clearer. Adding a sentence explaining why this error is actually what we wanted would make things clearer. Like "You don't see ' 1/1 test...' so it means the code did not compile successfully. What you are telling me are things specific to Zig that a I was not yet familiar with.
<Tetralux> The most obvious part is that it says "error:" honestly.
<Tetralux> That's probably what you'd be looking out for.
<yhoyhoj> Well, I didn't make the difference between an error and a stack trace :/
<Tetralux> But maybe it's worth pointing that out.
<Tetralux> I can see why you might have xD
ltriant has joined #zig
<yhoyhoj> Thanks for making this clearer. It may also be a worthy feedback. Better programmers may understand this by themselves but I think the introduction to a language should aim to be as easily understandable as possible.
<andrewrk> yhoyhoj, I agree with you on that. as zig gets more mature it will become more friendly to beginner programmers
<Tetralux> yhoyhoj: Welcome.
fu5ha has quit [Remote host closed the connection]
yhoyhoj has quit [Remote host closed the connection]