ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
donlzx has joined #zig
fjvallarino has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
quc has quit [Remote host closed the connection]
<andrewrk> this 501 http code s3 redirect thing is maddening
<andrewrk> I've half a mind to push a plain text file with a link to the latest instead of an actual redirect
<andrewrk> *301 not 501
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<MajorLag2> How much control do you get over it?
<andrewrk> none
<MajorLag2> well ok, that's a problem.
<MajorLag2> don't the advanced conditional redirect rules let you make it a 302? That page makes it look like they do
<andrewrk> what xml would you put in? I'm messing with that right now
<andrewrk> I tried this: <Redirect> <HttpRedirectCode>302</HttpRedirectCode></Redirect>
<andrewrk> "The XML you provided was not well-formed or did not validate against our published schema"
<andrewrk> tried matching 301 and got "The provided HTTP error code (301) is not valid. Valid codes are 4XX or 5XX."
<andrewrk> it worked! I had to remove the `/` at the beginning of the path
<MajorLag2> Cool. One more check off the todo list.
<andrewrk> I ran a cache invalidation so it should be correct now
<andrewrk> ugh now it's redirecting to the wrong place
<andrewrk> worse, it's redirecting from https to http
<andrewrk> what a disaster
<andrewrk> at least my m:n threading tests pass now on all OS's
<andrewrk> onwards!
<GitHub175> [zig] andrewrk pushed 1 new commit to master: https://git.io/fNUkx
<GitHub175> zig/master 10cc49d Andrew Kelley: define c macros before importing llvm h files...
<GitHub134> [zig] andrewrk pushed 1 new commit to master: https://git.io/fNUkh
<GitHub134> zig/master ccef60a Andrew Kelley: Merge pull request #1198 from ziglang/m-n-threading...
<GitHub25> [zig] andrewrk closed pull request #1198: M:N threading (master...m-n-threading) https://git.io/fbhxr
so has quit [Ping timeout: 260 seconds]
<GitHub97> [zig] andrewrk pushed 1 new commit to master: https://git.io/fNUIE
<GitHub97> zig/master b6eb404 Andrew Kelley: organize std.event into directories
so has joined #zig
v1zix has joined #zig
fjvallarino has quit [Remote host closed the connection]
fjvallarino has joined #zig
fjvallarino has quit [Ping timeout: 240 seconds]
<v1zix> Sorry for the basic question, but I was reading through the docs and was curious if there's a way to use a for loop to iterate over a range like for (i = 0; i < some_val; i++)? Or is that something intended for while loops to handle?
<MajorLag2> That's handled by while loops in zig. `for` specifically iterates over arrays and slices.
<v1zix> Cool, thanks
fjvallarino has joined #zig
<andrewrk> v1zix, no need to apologize - basic questions are on topic here
<stratact> Does Zig have iterators as well?
<andrewrk> no
<stratact> Are there plans?
<andrewrk> there's an open issue
davr0s has joined #zig
<andrewrk> there are no current plans to have iterators and no proposals in the issue tracker
<andrewrk> it's something I would consider when considering OOP, and something I would consider when considering generators (see #1194)
<stratact> andrewrk: I'm looking at the issue 809 and I have one thing to comment on. Iterators is not all about syntax bueaty, it's also about efficiency. What I do to make Rust programs more efficient, is that instead of passing arraylists or string buffers that which require allocation, is that I make custom iterator structs that would be passed around until iterated when needed.
<andrewrk> you can do that in zig too, no problem
<stratact> oh okay
<andrewrk> it just looks like while (it.next()) |item| { }
<stratact> ah right
<andrewrk> the only thing rust has on zig in terms of efficiency is noalias. see https://github.com/ziglang/zig/issues/1108 for that
<stratact> andrewrk: could you explain how noalias works in laymans terms, I'm curious what it is, but I'm having a hard time following in that issue
<wilsonk> Anybody else getting "zig/build/lib/zig/std/event/locked.zig:23:28: error: use of undeclared identifier 'Loop'". Just in the past few minutes when building the stage2 compiler?
<GitHub110> [zig] andrewrk pushed 2 new commits to master: https://git.io/fNUqc
<GitHub110> zig/master b5cfbfd Andrew Kelley: fix regression from b6eb4048
<GitHub110> zig/master 1b82a9d Andrew Kelley: enable basic event loop test
<andrewrk> wilsonk, my bad. just pushed a fix
<wilsonk> great, thanks :)
<andrewrk> wilsonk, note that stage2 only does `zig fmt` right now, but I'm working on it
<wilsonk> yep, I saw that. Just checking it out a little
<andrewrk> I just got M:N threading in std.event.Loop working on all supported targets, so the stage2 compiler is going to be fully parallel
<andrewrk> with no mutexes
<stratact> oh okay, so noalias forces pointers to not point in the same memory location?
<andrewrk> stratact, that's correct
<andrewrk> aliasing is when the same data is accessed via multiple pointers
<stratact> oh I see now
<andrewrk> the more you can tell the compiler/optimizer about all the ways in which you are not aliasing, the better
<andrewrk> you will note that a lot of libc APIs have `restrict` on them, when there are more than 1 pointer parameter
<andrewrk> such as memcpy
<stratact> gotcha, so it makes it safer that way
<andrewrk> it's actually less safe
<andrewrk> because when you require that parameters do not alias, then it's undefined behavior if you pass pointers that alias each other
<andrewrk> and the lack of safety lets the optimizer make things faster
<stratact> understood. Although I assume the debug checking mechanisms will alert Zig programmers if there are possible uses of undefined behavior
<andrewrk> that's the idea
<andrewrk> it's not possible for every kind of undefined behavior
<andrewrk> but we can catch a lot of mistakes
<stratact> well I'm sure as Zig will evolve, so will the debug checker, for accounting more possible undefined behavior possibilities?
<andrewrk> indeed. but here's an example of something you can never prevent: you call an extern function, which looks at the return address, adds a random offset, and randomly modifies the memory there
<andrewrk> zig can never detect this
<andrewrk> hmm that's not the best example, because this would affect rust too
<stratact> gotcha
<andrewrk> there will always be some way to make dangling pointer references in a way zig cannot detect
<GitHub12> [zig] wilsonk opened pull request #1212: Emit error when compiling undefined function pointer. Fixes #880. (master...undefined_function_pointer) https://git.io/fNUqi
<andrewrk> also, if you build in release-fast mode and run into an untested code path that has undefined behavior, there would be no safety there
<andrewrk> wilsonk, thanks for the PR! I'll have a look tomorrow morning
<wilsonk> sounds good
<stratact> Hmm, I guess I will need to know when code is undetectable unsafe than detectable unsafe
<stratact> if that's the right way to describe it?
darithorn has quit [Quit: Leaving]
<stratact> andrewrk: I mean, is there documentation about parts of the language that have uncertainty in checking?
<stratact> oh right, it's impossible to account for all possibilities, like you said...
v1zix has quit [Ping timeout: 252 seconds]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
xtreak has joined #zig
very-mediocre has joined #zig
wilsonk_ has joined #zig
wilsonk has quit [Read error: Connection reset by peer]
quc has joined #zig
xtreak has quit [Remote host closed the connection]
zolk3ri has joined #zig
very-mediocre has quit [Ping timeout: 252 seconds]
alexnask_ has joined #zig
xtreak has joined #zig
Richard10 has joined #zig
<Richard10> while with Optionals: The else branch is allowed on optional iteration. In this case, it will be executed on the first null value encountered. For allows an else attached to it, the same as a while loop.
<Richard10> But in this code, when it encounter null, the code in else is not executed.
<Richard10> test "for else" { // For allows an else attached to it, the same as a while loop. var items = []?i32 { 3, 4, null, 5 }; // For loops can also be used as expressions. var sum: i32 = 0; const result = for (items) |value| { if (value == null) { break 9; } else { sum += value.?; } } else blk: { assert(sum == 7); break :blk sum; }; }
wilsonk has joined #zig
wilsonk_ has quit [Read error: Connection reset by peer]
skyfex has quit [Quit: Textual IRC Client: www.textualapp.com]
zolk3ri has quit [Ping timeout: 256 seconds]
zolk3ri has joined #zig
zolk3ri has quit [Ping timeout: 268 seconds]
zolk3ri has joined #zig
xtreak has quit [Remote host closed the connection]
xtreak has joined #zig
very-mediocre has joined #zig
xtreak has quit [Ping timeout: 260 seconds]
very-mediocre has quit [Ping timeout: 252 seconds]
Richard10 has quit [Ping timeout: 252 seconds]
Hejsil has joined #zig
fjvallarino has quit [Remote host closed the connection]
fjvallarino has joined #zig
Hejsil has quit [Quit: Page closed]
<GitHub81> [zig] andrewrk pushed 1 new commit to master: https://git.io/fNUFY
<GitHub81> zig/master 28f9230 Andrew Kelley: fix crash when calling comptime-known undefined function ptr...
<GitHub166> [zig] andrewrk closed pull request #1212: Emit error when compiling undefined function pointer. Fixes #880. (master...undefined_function_pointer) https://git.io/fNUqi
<GitHub134> [zig] andrewrk pushed 1 new commit to master: https://git.io/fNUAq
<GitHub134> zig/master 696ef0b Andrew Kelley: langref: docs for union safety
Ichorio has joined #zig
donzx has joined #zig
donlzx has quit [Ping timeout: 276 seconds]
fjvallarino has quit [Remote host closed the connection]
fjvallarino has joined #zig
fjvallarino has quit [Remote host closed the connection]
isd has joined #zig
dpk has quit [Quit: .]
dpk has joined #zig
fjvallarino has joined #zig
<GitHub133> [zig] andrewrk pushed 1 new commit to master: https://git.io/fNTUm
<GitHub133> zig/master 0ce6934 Andrew Kelley: allow var args calls to async functions
shiv has joined #zig
noonien has joined #zig
fjvallarino has quit [Remote host closed the connection]
redj_ has joined #zig
redj has quit [Ping timeout: 268 seconds]
douglas has joined #zig
donzx has quit [Quit: Leaving]
fjvallarino has joined #zig
fjvallarino has quit [Remote host closed the connection]
fjvallarino has joined #zig
<GitHub126> [zig] wilsonk opened pull request #1213: Possible fix for #778. Two cases. (master...generic_function_argument) https://git.io/fNTYB
jwmerrill has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
alexnask_ has quit [Ping timeout: 260 seconds]
jwmerrill_ has joined #zig
jwmerrill_ has quit [Client Quit]
jwmerrill has quit [Ping timeout: 252 seconds]
vegecode has joined #zig
davr0s has joined #zig
<vegecode> Could someone tell me how they approach debugging the compiler? I can't get breakpoints or anything to be hit with lldb so I've resorted to printf style. I had a case that would always get to zig_unreachable but my breakpoint in zig_panic (which is wrapped by zig_unreachable) was never hit. The process just terminated.
<vegecode> If you use gdb or lldb, what arguments do you pass?
<andrewrk> vegecode, I use gdb on linux, lldb on macos, and msvc on windows
<andrewrk> breakpoints work in all of them
<andrewrk> gdb path/to/zig
<vegecode> ok thanks.
<douglas> Where would I find zig libraries? I am looking for regex in particular.
<andrewrk> douglas, there is not one in std yet but I know that tiehuis has one in progress
<andrewrk> I'll have a better answer for you about zig libraries once we have the package manager all sorted out
<douglas> Thanks. I guess I could use a C lib?
<andrewrk> yep
<vegecode> I don't remember the name of the file but I think it was compiler_rt.o or something like that which is generated for each target to be used in place of libc calls like memset and such? I have to use the --emit-asm option and so there is obviously then no object file created, but there is also no asm file like that either. Is it possible to generate that as an asm file?
<vegecode> Not a huge deal, just wondering how much I can go straight zig at this point.
<andrewrk> vegecode, yes it is possible
<andrewrk> there are 2: builtin.o and compiler_rt.o
<andrewrk> builtin has memset/memcpy and some others, and compiler_rt has udivmod, fixunsdfdi, etc
<vegecode> I'm guessing I can just compile builtin.zig and compiler_rt.zig with --emit-asm option then
<vegecode> There is no compiler_rt.zig in the zig source and there's no object file in the zig-cache for my project with assembly. Where is compiler_rt.o compiled from?
<andrewrk> vegecode, bin/zig build-obj ../std/special/compiler_rt/index.zig --emit asm
<andrewrk> (you'll need your --target arguments)
<andrewrk> bin/zig build-obj ../std/special/builtin.zig --emit asm
<vegecode> Thanks. I really appreciate it.
<andrewrk> vegecode, I noticed an assertion trip when I used --output for the compiler_rt case, but I think you can get it to be compiler_rt.s if you use --name compiler_rt
<vegecode> Ok. I will mess with it tonight. Thanks.
<douglas> Is there a zig forum yet?
very-mediocre has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<andrewrk> we have a subreddit
<douglas> Nice
vegecode has quit [Ping timeout: 252 seconds]
mahmudov has joined #zig
Bas_ has joined #zig
<Bas_> Is it actually fine to modify the .len on a slice?
<Bas_> I mean... it works... but I'm not sure if it's actually supposed to be used like that.
<andrewrk> Bas_, probably it will be a compile error to do that before 1.0.0
root__ has joined #zig
<Bas_> Alright, I'll change my code then.
<GitHub48> [zig] andrewrk pushed 1 new commit to master: https://git.io/fNT0e
<GitHub48> zig/master 8fba0a6 Andrew Kelley: introduce std.event.Group for making parallel async calls
root__ is now known as jwmerrill
davr0s has joined #zig
peyty has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
very-mediocre has quit [Quit: Page closed]
<douglas> Just tried cross compiling Linux <=> Windows... It worked great :-)
tankf33der has left #zig [#zig]
<andrewrk> douglas, happy to hear that :)
<andrewrk> C libraries are still problematic in that regard, but I have a plan for that
<Bas_> Do we have lambdas?
davr0s has joined #zig
<Bas_> Ah yeah I actually saw the second one already.
<Bas_> And is there an easy way to get the last element from a slice?
<Bas_> or do I have to do slice[slice.len - 1]?
unique_id has joined #zig
<andrewrk> that's the best way to do it
<Bas_> ok
<andrewrk> Bas_, there's a workaround to put a function inside a function available
<andrewrk> you put it in a struct
<andrewrk> there are a couple of known bugs with it, such as if there are any defers in scope it will crash the compiler
<Bas_> I actually have a predicate which I want to invert to pass to another function.
<Bas_> I mean, can it capture parameters from inside the function?
<andrewrk> only comptime-known ones
<andrewrk> so it does not have the ability to be a closure
<Bas_> Ok, that'll do for now I guess.
Ichorio has quit [Read error: Connection reset by peer]
shiv has quit [Ping timeout: 252 seconds]
noonien has quit [Quit: Connection closed for inactivity]
<unique_id> Hi. I thought that I'd announce that I'm going to be using Zig full time. Being self employed (or not working), I'm in a great position to do this. I'm trying to specialize in a category of games that hit a really nice ratio of interest-in-game/effort and it fits to be using a language that hits a really nice ratio of features/complexity. I don't mind bugs or even radical language redesigns.
<andrewrk> unique_id, wow! that's really exciting
<andrewrk> let me know if you run into any blockers and I'll try to keep you moving along :)
<wilsonk> sweet
Bas_ has quit [Ping timeout: 252 seconds]
<unique_id> will do, thanks
zolk3ri has quit [Quit: leaving]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
isd has quit [Quit: Leaving.]
fjvallarino has quit [Remote host closed the connection]
fjvallarino has joined #zig
fjvallarino has quit [Remote host closed the connection]
fjvallarino has joined #zig
quc has quit [Ping timeout: 240 seconds]
quc has joined #zig
alexnask_ has joined #zig
douglas has quit [Ping timeout: 252 seconds]
fjvallarino has quit []