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/
<data-man> andrewrk Now I am testing Zig grammar.y, it is slightly incorrect. PR is welcomed? :)
<andrewrk> data-man, yes
<data-man> Just an idea: online check sources via PEGJS. What you think?
clktmr has quit [Ping timeout: 265 seconds]
<andrewrk> I think I will be ok to let things break occasionally until the language has stabilized
data-man has quit [Ping timeout: 260 seconds]
tridactyla has quit [*.net *.split]
tracernz has quit [*.net *.split]
tracernz has joined #zig
tridactyla has joined #zig
plumm has quit [Quit: Lost terminal]
data-man has joined #zig
<data-man> Why is there no loop with post-condition in Zig? Something like repeat/until (e.g. Lua, Pascal) or do/while (e.g. C, D). It's very useful in many cases.
<scientes> data-man, that was rejected
<scientes> its easy to implement to
<scientes> the only thing that really ticks people is that you have to declare your loop index in the outside scope
<data-man> Please revote for this! :)
<scientes> meh, its not a big deal
<scientes> the loop index is the only thing that is kinda annoying
<data-man> Is there no special optimization for do/while in LLVM?
<andrewrk> correct, there is none
<scientes> and hardware loops are generated by an optimization pass
<scientes> data-man, so there is, the PPC pass, that has been generalized into the PPC+ARM-M hardware loop pass
<Snektron> scientes: you have to declare that outside the loop anyway in zig
<scientes> data-man, this talk, the video should be up soonish https://llvm.org/devmtg/2019-10/talk-abstracts.html#tech2
<scientes> but llvm-9 has the codegen
<data-man> Yet another proposal: LLVM has builtin llvm.readcyclecounter. Would be nice to have it in Zig, especially for benchmarking. I tried to implement this but still not well studied the source code of the compiler.
<data-man> scientes thanks!
<andrewrk> data-man, this is a good proposal - can you open an issue with this?
<data-man> Sure.
<scientes> there is also talk about coverting all recursive calls in llvm to loops
tracernz has quit [*.net *.split]
tridactyla has quit [*.net *.split]
<scientes> *most
<andrewrk> it will still look close enough to recursion though
<scientes> yeah but it generalizes the optimzations
<scientes> and compilers are all about normalization
<andrewrk> specifically fact-await.zig - there is an example of recursion that will always be allowed
<scientes> this was brought up at the dev mtg in a round-table, and basically someone knows all the issues, but doesn't have time to implement it
<andrewrk> what are you talking about scientes? recursion?
<scientes> yes
<scientes> lowering recursion into loops
<andrewrk> ah. unfortunately zig will not be able to take advantage of any such feature
<data-man> Also would be nice to have builtin prefetch. I'm not sure about the proposed syntax yet. :)
<scientes> just means you write an alloca() in your loop, which is generally frowned upon :)
tracernz has joined #zig
tridactyla has joined #zig
<andrewrk> scientes, well if you can tail recurse, zig will allow this
<scientes> anyways, i should read the proposal
<andrewrk> otherwise you need a heap allocation to avoid unbounded stack growth
<andrewrk> thank you data-man
<frmdstryr> @andrewrk is the code from your chat demo in a repo somewhere?
<andrewrk> dimenus, extern struct will be a good workaround for you until #3133 is done. the memory layout of extern structs is well defined, and it's the same as C ABI
<andrewrk> frmdstryr, I'll make a gist for you. here: https://gist.github.com/andrewrk/4ca4badce653619d0804464c2e400220
<frmdstryr> Thanks!
<andrewrk> scientes, after a discussion in #llvm I'm convinced that we should move forward, for now, with my strategy of vector array element pointers. the one that has metadata in the type, and does not assume any memory layout of vectors
<andrewrk> I'm pretty sure this is compatible with all your test cases anyway
<scientes> not adding 1
<scientes> doing pointer arithmatic
<scientes> I had a talk with jdoeffert in #llvm about this
<scientes> and he said use GEP
<andrewrk> tomorrow, end of day, #3580 will be closed and #3575 will be closed, and dimenus's examples will work (except for vector literals which is not happening, see #208)
<andrewrk> and we can move on with the rest of simd
<scientes> yeah I don't really care about vector literals
<scientes> it was just brought up in a bug and I didn't care
<scientes> ok my patch no longer allows vector literals
<scientes> *PR
return0e has quit [Ping timeout: 240 seconds]
return0e has joined #zig
<dimenus> yeah i didn't need literals, i just did it on accident
<dimenus> and noticed it segfaulted
data-man has quit [Ping timeout: 260 seconds]
keithdc has quit [Quit: Lost terminal]
<dimenus> andrewrk & scientes: was there a final decision on indexing vectors then?
<scientes> if I had some good example code on using ResultLoc I could finish a patch on the way I want to do it, and demonstrate that it works
<dimenus> i can't grok it yet, need to spend more time digging in the compiler
<scientes> ahhh crlf is causing me grief
<scientes> as the softfloat library has crlf, and now git is trying to be too smart
dimenus has quit [Killed (card.freenode.net (Nickname regained by services))]
dimenus has joined #zig
<andrewrk> dimenus, yes, it generally works just fine, but the pointer type is not simple. have a look at the test cases in my PR
Guest10860 has joined #zig
<andrewrk> dimenus, your second test case does not yet pass in my PR, but I will make it work
<dimenus> that one at least makes intuitive sense to me, it would be consistent with `var foo: @Vector(4, f32) = [_]f32 { 1, 2, 3, 4 }`
ltriant has joined #zig
<andrewrk> yes it is supposed to work
tridactyla has quit [*.net *.split]
tracernz has quit [*.net *.split]
waleee-cl has quit [Quit: Connection closed for inactivity]
<scientes> oh, so you DO want vector literals?
<scientes> I am confused
ltriant has quit [Ping timeout: 268 seconds]
<dimenus> scientes: no i think he's referring to the second test i posted on your PR (which is the same one you posted on his PR)
<scientes> except that i tested the value
<scientes> i got your version working
<scientes> it just isn't setting anything
<scientes> cause it needs a ResultLoc to know what to set
tridactyla has joined #zig
tracernz has joined #zig
dimenus has quit [Remote host closed the connection]
dimenus has joined #zig
marijnfs_ has joined #zig
marijnfs has quit [Ping timeout: 245 seconds]
tracernz has quit [*.net *.split]
tridactyla has quit [*.net *.split]
tracernz has joined #zig
tridactyla has joined #zig
data-man has joined #zig
<data-man> scientes https://github.com/ziglang/zig/issues/3600 - prefetch proposal
<scientes> prefetch is rarely useful
<scientes> on modern processors
<scientes> I don't really see the point
<scientes> basically, it is useless on OOO processors
<scientes> it is only useful on in-order processors
dimenus has quit [Ping timeout: 265 seconds]
<scientes> is there a blog post?
Guest10860 has quit [Ping timeout: 265 seconds]
<scientes> data-man, you did see my @expect PR right?
data-man has quit [Ping timeout: 260 seconds]
data-man has joined #zig
<data-man> Sure I saw.
<scientes> wow, considerable difference
<scientes> even on an OOO processor
<scientes> a write prefetch is bizaare
<pixelherodev> That -
<pixelherodev> What does that even mean?
<pixelherodev> What's a write prefetch?
<scientes> > rw is the specifier determining if the fetch should be for a read (0) or write (1)
<pixelherodev> ...okay but
<pixelherodev> *What does it mean*
<scientes> you tell the CPU where you are writing
<pixelherodev> How can it prefetch that though?
<pixelherodev> That makes no sense
<pixelherodev> Wait, so it fetches the data that will be written?
<scientes> well, that is what it does on intel
<pixelherodev> ... okay that actually makes some sense but for one point
<pixelherodev> Why is it needed?
<pixelherodev> Isn't that semantically identical to a read prefetch of that data?
<pixelherodev> Why add a second opcode when one would suffice
<pixelherodev> ?
<scientes> that is done all the time
Jezza__ has joined #zig
<scientes> to encode additional meaning
<scientes> for forwards compatibility
* pixelherodev shrugs
<pixelherodev> Just seems wasteful to me
<pixelherodev> Then again, I like tinkering with 8-bit CPUs, so I definitely have a skewed perspective :P
<scientes> pixelherodev, i think you are a waste of a ipv4 address /sarcasm
<pixelherodev> My pedantic side feels like pointing out that I'm not an ipv4 address ;)
<scientes> yeah but you are connected to freenode via one
Ichorio_ has quit [Ping timeout: 245 seconds]
doublex has quit [Ping timeout: 264 seconds]
<pixelherodev> Yes, but *I* wouldn't be the waste of an address
<pixelherodev> Maybe the waste of a TCP connection
<pixelherodev> Or, rather, my connection would be a waste
data-man has quit [Ping timeout: 260 seconds]
<scientes> yeah but its znc
<scientes> and you rent that service that uses the ipv4 address
<scientes> so if you were kicked off the net you wouldn't use it
<scientes> anyways.....
<scientes> its like saying someone isn't worth the bullet it would be required to shoot them
<pixelherodev> That reminds me of the thieves who shot $50 of ammo into the ceiling to intimidate the cashier when there was only $20 in the register :)
<pixelherodev> On a more Zig-related topic: how difficult would a Zig to C translation layer be?
<pixelherodev> A lot of things map 1:1, but advanced stuff like async/await could theoretically map to e.g. pthreads
<scientes> pixelherodev, we already have that
<scientes> zig translate-c
<pixelherodev> ... that's C->Zig
<scientes> ooooh
<pixelherodev> I'm talking the opposite
<scientes> pixelherodev, there is a llvm-to-c translator
<scientes> so there is no motivation
<pixelherodev> Also, isn't translate-c header-only?
<pixelherodev> scientes, no there isn't.
<pixelherodev> It's defunct.
<pixelherodev> And the modern "upgraded" version apparently outputs awful code from what I've heard
<scientes> well, I don't see the reason
<scientes> llvm is quite portable
<pixelherodev> Yes, but C is even more so
<scientes> yeah but its lower quality
<pixelherodev> e.g. SDCC can produce code for a bunch of small targets
<pixelherodev> Sure, but as effectively a compiler backend it doesn't matter
<pixelherodev> It's basically an intermediate format like LLVM IR normally is
<scientes> yeah but if you are transpiling you are going to get bloated code
<scientes> that won't run on such targets
<pixelherodev> I don't think it would have to be *too* bloated
<pixelherodev> Not if it was Zig->C with no intermediate layer like LLVM
<scientes> and people don't really write c89 these days anyways
<pixelherodev> I know, I typically use C99
<scientes> so again, its just not worth the effort
<scientes> the path of least resistance is to port llvm
<pixelherodev> I might look into making a transpiler of a small subset of Zig then
<pixelherodev> If I'm the only who uses it, that's fine :)
<scientes> I'd rather see more zig targets
doublex has joined #zig
<pixelherodev> Yes, but I don't have the knowhow for that
<pixelherodev> I've read the LLVM docs
<scientes> what is the target?
<pixelherodev> The abyss stared back.
<pixelherodev> XTensa
<scientes> hmm, there were other DSP vectors at the llvm conference
<torque> espressif might actually finish their llvm xtensa backend in the next decade
<torque> patience solves all problems
* scientes sometimes watches grass grow
<pixelherodev> Yeah, but I'm not going to need it after ~four months from now probably
<pixelherodev> So there's no point in waiting
<pixelherodev> If I got a minimal subset working in a week, that'd at least be mildly usable
<scientes> yeah, but then why not just write in C?
<pixelherodev> Because I am and I miss Zig!
<pixelherodev> :(
<pixelherodev> Seriously though, I knew C had problems (even if it was the least bad option for many of my projects), but Zig is freaking *amazing*. I honestly haven't had any problems with the language.
<pixelherodev> Any problems I've had are compiler bugs, and those are transient
data-man has joined #zig
<data-man> pixelherodev: because "add a builtin function for every llvm C library intrinsic and bit manipulation instrinsics #767" :-D
ky0ko has joined #zig
ltriant has joined #zig
muffindrake has quit [Ping timeout: 246 seconds]
data-man has quit [Ping timeout: 260 seconds]
muffindrake has joined #zig
ltriant has quit [Ping timeout: 240 seconds]
<pixelherodev> ?
<pixelherodev> What's that in response to?
<pixelherodev> The prefetch thing?
data-man has joined #zig
<data-man> pixelherodev: yes
<scientes> i've added bazillions
<scientes> have have some WIP patches for a few more
<scientes> was just thinking of llround
<scientes> and that it probably should return a smaller integer
<scientes> and a biger one for f128
<scientes> declare i64 @llvm.lround.i64.f128(double %Val)
<scientes> but the significand is 112 vits
<scientes> *bits
<scientes> so it should return a i112
data-man has left #zig [#zig]
fsateler has quit [Ping timeout: 276 seconds]
fsateler has joined #zig
mahmudov has quit [Ping timeout: 268 seconds]
chemist69 has quit [Ping timeout: 252 seconds]
chemist69 has joined #zig
fsateler has quit [Ping timeout: 276 seconds]
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen has joined #zig
doublex_ has joined #zig
doublex has quit [Ping timeout: 240 seconds]
<daurnimator> andrewrk: how long until/what triggers docs to be uploaded to https://ziglang.org/documentation/master/std/ ? ==> I was expecting to see the fifo stuff there
ltriant has joined #zig
tracernz has quit [*.net *.split]
tridactyla has quit [*.net *.split]
tracernz has joined #zig
<daurnimator> companion_cube: I found doing bit operations on huge (fixed width) integers nicer than doing in on what would otherwise be e.g. a [64]u8
ltriant has quit [Ping timeout: 240 seconds]
fsateler has joined #zig
<pixelherodev> There a plan for 0.5.1 release soon?
<daurnimator> pixelherodev: not unless there's a huge breakage
<daurnimator> pixelherodev: for some reason andrew doesn't do point releases.... releases are 6-monthly
<pixelherodev> On a different note, anyone know who maintains the Alpine package?
<daurnimator> mps apparently. why?
<pixelherodev> Was going to ask what the zig-dev package is
<pixelherodev> "... development files"
<daurnimator> Yeah that's weird+wrong.... they seem to have split off all the shipped libcs into a separate package
<daurnimator> You can probably bring it up in the alpine channel
<pixelherodev> Added to my todo list
<pixelherodev> Don't want to have to deal with followup right now; I'll probably bring it up tomorrow
<pixelherodev> Or better yet, send a patch myself :)
<pixelherodev> But yeah, I got curious about versions because apparently 0.5 is before `-I` was added to zig
<pixelherodev> So my `rsync /path/to/backup/ /home/ -av` wasn't enough to get it working after I set up my PC a few days ago :(
<pixelherodev> Guess I'll have to build Zig from scratch
<pixelherodev> Again.
<pixelherodev> Maybe I can copy my ccached files over :P
<pixelherodev> Oh wait - they'd be included in that backup, and so should a working build :D
<pixelherodev> Until I felt the need to `git pull` it and now I have to re-make it. Because of course I did.
_whitelogger has joined #zig
<pixelherodev> Yay, everything's working again :D
<pixelherodev> Is a build targeting x86_64-linux-musl static? Or is there a separate target for static builds?
<pixelherodev> Never mind, tested and it's static. That's awesome!
reductum has joined #zig
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
<mq32> hey pixelherodev
* mq32 has lost total control of himself yesterday and coded till 2:30am
<mq32> and now: i may present the first x86 fake assembler written in zig that runs on freestanding:
<reductum> Could anyone point me in the direction of something in the stdlib that will let me run a separate program? Should I just build on top of std.os.linux.execve?
<pixelherodev> mq32, nice :)
<pixelherodev> I just got a working static build of my project for Github's Game Off jam :D
<mq32> nice
<pixelherodev> Not quite 45 bytes small (apparently the smallest quasi-legal ELF file you can make for x86 :P), but pretty good
mahmudov has joined #zig
<mq32> pixelherodev: Game Off Jam would be a funny idea
<mq32> "yeah, my entry is a pretty small game written for a virtual console i have written during the jam time" :D
<pixelherodev> ?
<pixelherodev> Ah
<pixelherodev> Yeah, mine builds both as a static linux build (which is still freaking awesome) and with the LIMNOS kernel (the x86 project I've been working on) as a backbone
<pixelherodev> Which is a good thing, because it means I can provide a build most people can actually *use*
<pixelherodev> I mean, if they're willing to open a terminal ;)
<pixelherodev> Should probably figure out how to do that for Windows too, but I don't think there's a termios equivalent, which i need to put the input in the expected format
reductum has quit [Quit: WeeChat 2.6]
ltriant has joined #zig
<muffindrake> What is a comptime_int, more precisely?
<mq32> muffindrake: it's an arbitrarily sized integer type that can only be used at comptime
<mq32> it casts implicitly in all integer types that can capture the value the comptime_int has
<muffindrake> That's helpful to know, thanks!
<mq32> i just noticed how much difference it is between "debug" and "release-fast" mode
<pixelherodev> Anyone know a way to do the equivalent of `stty -echo -icanon` on Windows?
ltriant has quit [Quit: leaving]
<mq32> pixelherodev: you should read the docs on how the windows "terminal" works
<pixelherodev> Probably, but they scare me
<mq32> a tl;dr is probably just "it's actually just a character buffer"
<mq32> not a terminal emulator
<mq32> so everything "terminal like" you see is user space
<mq32> at least to my understanding
<pixelherodev> Alright thanks
<pixelherodev> Anyway, night
<mq32> <pixelherodev> Anyway, night
<mq32> it always confuses me that we all have different time zones here
<mq32> i'm on my way to work right now
<mq32> :D
kllr_sbstn has joined #zig
dch has quit []
dch has joined #zig
Jezza__ has quit [Read error: Connection reset by peer]
Jezza__ has joined #zig
achaninja has joined #zig
kllr_sbstn has quit [Remote host closed the connection]
return0e_ has joined #zig
return0__ has joined #zig
return0e_ has quit [Ping timeout: 250 seconds]
return0e_ has joined #zig
return0__ has quit [Ping timeout: 276 seconds]
return0e has quit [Read error: Connection reset by peer]
return0e has joined #zig
frmdstryr has quit [Remote host closed the connection]
return0__ has joined #zig
dantix has joined #zig
return0__ has quit [Remote host closed the connection]
return0__ has joined #zig
return0e_ has quit [Ping timeout: 252 seconds]
Guest10860 has joined #zig
Guest10860 has quit [Remote host closed the connection]
ky1ko has quit [Remote host closed the connection]
dimenus has joined #zig
achaninja has quit [Ping timeout: 260 seconds]
return0__ has quit [Remote host closed the connection]
return0e_ has joined #zig
<Cadey> andrewrk: i just submitted a tag proposal for the zig tag on lobste.rs
mahmudov has quit [Ping timeout: 265 seconds]
waleee-cl has joined #zig
dimenus|work has joined #zig
dimenus|work has quit [Client Quit]
return0__ has joined #zig
return0e_ has quit [Ping timeout: 268 seconds]
<leeward> Are there examples out there of libraries written in C that have been partially converted to Zig? I'd like to look at how the build system and environment are set up.
<dimenus> leeward: check out 'Zig in the Wild' https://ziglang.org/
<dimenus> some of those projects might contain some c code still
return0__ has quit [Remote host closed the connection]
return0e_ has joined #zig
emekankurumeh[m] has joined #zig
protty has joined #zig
<mq32> dimenus: oh wow that zig looks so unusual :D
<mq32> it's zig 0.3 or before, right?
return0e_ has quit [Remote host closed the connection]
<dimenus> mq32: I would imagine so. blog post is 2017
<dimenus> that was before the great desigiling :D
return0e_ has joined #zig
return0e_ has quit [Read error: Connection reset by peer]
return0__ has joined #zig
<mq32> hehe
<mq32> i hope the syntax won't change much from now, it's already quite comfortable
<dimenus> i agree, i was 'meh' on it in 2017, but I've come around big time
<emekankurumeh[m]> how would one go about adding a new abi to zig?
<dimenus> andrewrk: do you know if anyone has proposed a '@extern' or something similar to specify a symbol name just for linking purposes?
<dimenus> or would the recommended zig way to do things just be to const realFnName = _linkFnName;
<emekankurumeh[m]> that's @export
<dimenus> i'm not exporting a symbol here, i want to link with one in a different o file
<dimenus> emekankurumeh[m]: i don't think that's correct, in this case the symbol originates from non-zig code
<dimenus> i want to call the fucnction by another name (not it's link name) within the zig code base
<mq32> dimenus: *this* could work:
<mq32> usingnamespace struct { extern fn myExternFunctionWithStupidName() void; pub const myFunkyName = myExternFunctionWithStupidName; };
<dimenus> ah yeah, so it's basically what i thought. No builtin needed. thanks :)
<mq32> probably even better would be
<mq32> const myFunkyName = struct { extern fn myExternFunctionWithStupidName() void; }.myExternFunctionWithStupidName;
wink_ has joined #zig
dimenus has quit [Read error: Connection reset by peer]
dimenus has joined #zig
shodan45 has quit [Remote host closed the connection]
return0e has quit [Read error: Connection reset by peer]
return0e has joined #zig
bentxt has joined #zig
<bentxt> hello, dear zigs
return0__ has quit [Remote host closed the connection]
return0e_ has joined #zig
<bentxt> I don't have a lot of experience with c. Do you consider c a requirement for zig, or does zig makes it easier for beginners to work with manual memory management?/
<andrewrk> bentxt, C knowledge would help you, but you can learn Zig without knowing C
<andrewrk> zig is immature and there are compiler bugs, this is a downside. but on the upside, you get nice things like stack traces for segfaults
<leeward> dimenus: thanks
<dimenus> it also provides a lot of useful collections and a ton of examples between the tests and standalone exes
<leeward> Also keep in mind that the language isn't done. So in addition to compiler bugs, there's an extra maintenance burden on any code you write to port to newer versions of the language.
<andrewrk> bentxt, I would be curious to hear what your thoughts are as a beginner after reading http://ziglang.org/documentation/master/ - what things are you unclear on
FireFox317 has joined #zig
<FireFox317> andrewrk: What raspberry pi will you be giving the demo on? I saw you asked for usb keyboard support, I would like to try to figure that out
<andrewrk> FireFox317, rpi 3 B+
<andrewrk> my fallback demo is a bouncing dvd logo
<andrewrk> will it hit the corner??
<edr> lol
<scientes> you should make it not do a 1x1 diagonal move
<scientes> so it always hits the corners
wootehfoot has joined #zig
<mq32> implement a corner prevention algorithm that applies a force to the logo if it comes near a corner
protty has quit [Ping timeout: 260 seconds]
mikdusan has quit [Ping timeout: 268 seconds]
<scientes> why is that a problem?
<scientes> or maybe its to prevent people from getting satisfaction?
<mq32> i remember some demo program that did exactly this
<mq32> bouncing dvd logo but had like ... 10 different versions on preventing the logo from ever entering a corner
<scientes> but i proposed a version where it ALWAYS hits the corners
<scientes> even taking non-straight paths
<mq32> logo splits and hits *all* corners at the same time
FireFox317 has quit [Ping timeout: 240 seconds]
return0e_ has quit [Remote host closed the connection]
return0e_ has joined #zig
return0e_ has quit [Ping timeout: 268 seconds]
mikdusan has joined #zig
Akuli has joined #zig
protty has joined #zig
traviss has quit [Quit: Leaving]
FireFox317 has joined #zig
<FireFox317> andrewrk: did you test the latest clashos on hardware?
<andrewrk> FireFox317, no. I haven't tested on real hardware since before merging markfirmware's patches
<andrewrk> was planning on doing that this week
<FireFox317> Okay, because I got it working before with markfirmware's patches, but can't get it working now
<FireFox317> One thing I remember when it worked on real hardware, was that the bootloader did not work anymore
protty has quit [Ping timeout: 260 seconds]
<mq32> andrewrk, FireFox317: is the code for stack traces in ClashOS working with master?
<mq32> i'm on "low internet connection" and i don'T want to load any more web pages than necessary
<andrewrk> mq32, no, that regressed with markfirmware's patches. I'm planning on reverting them all and redoing the work myself
<mq32> hm, okay. sad :D
* mq32 is going to read a lot in the dwarf code to get your blog entry running
<mq32> am i seeing this right that zig assumes '\n' is a "line break"?
<mq32> (instead of a line feed)
ky1ko has joined #zig
<dantix> hi, is there a way to attach additional data to an error?
ky0ko has quit [Disconnected by services]
ky1ko is now known as 07IAC3ALV
ky0ko has joined #zig
ky0ko has quit [Disconnected by services]
07IAC3ALV is now known as ky0ko
<dantix> `FileNotFound` is cool and everything, but it would be more useful to know file path. or json parsing failed, which line and character was at fault.
ky0ko_ has joined #zig
<mq32> you can always inspect the state of your system, even after an error was returned
<mq32> but no, it's not possible to attach additional information to an error
<dantix> hm, how I can inspect state? if I to use `errdefer` or `defer` state is gone at that point
<andrewrk> alright scientes, vector element access is in master. bring on the next SIMD PR.
<companion_cube> the chat server stream is pretty cool
<companion_cube> but I'm quite frightened by async/await and how implicit it is :s
return0e_ has joined #zig
<andrewrk> I think you're confusing async/await with the std lib event loop + std.io.mode
<companion_cube> right, right, but still, whether stuff blocks or not is super implicit
<mq32> huh. i found two compiler bugs with one line of code :D
<mq32> have to prepare a stripped down version of this, but shouldn't be that hard...
Kappa322 has joined #zig
<andrewrk> companion_cube, isn't that how it always works? in hosted code, the kernel can preempt at any time
<Kappa322> Using zig to build C, is there a way to add include directories as -I<directory> other than manually with addBuildOption?
tridactyla has joined #zig
<Kappa322> There's only addIncludeDir as far as I can see but that does it with -isystem
<andrewrk> Kappa322, you're using build.zig?
<Kappa322> Yep
return0e_ has quit [Remote host closed the connection]
return0e_ has joined #zig
<andrewrk> addCSourceFile takes a parameter which is a list of c flags. but addIncludeDir is the preferred way. is -isystem problematic for some reason?
return0e_ has quit [Remote host closed the connection]
<Kappa322> My project has a common library which is part of the project and I want it in the include path; using -isystem warnings and such would be ignored for those header files iirc
<andrewrk> Kappa322, also, I'm running tests locally for a patch that makes addIncludeDir use -I instead of -isystem, and addSystemIncludeDir is newly available
<andrewrk> will push that to master in a few minutes
<Kappa322> Awesome, thanks
return0e_ has joined #zig
<companion_cube> andrewrk: preemption with other processes is quite different than preemption within a sequential looking function
<Kappa322> Loving the motivation behind zig and the path you're taking it so far btw, keep it up!
<andrewrk> companion_cube, I'm probably going to agree with you, but humor me and let's go through the reasoning
<companion_cube> well, preemption from the kernel is generally transparent (with the terrible exception of signals 😱); in a process it means any shared state could change anywhere
<companion_cube> maybe I didn't understand your comment in the stream about blocking calls meaning that the caller might resume in a different thread though
<andrewrk> in a multi-threaded process any shared state can change anywhere
kllr_sbstn has joined #zig
<companion_cube> well here the thing is, everything is shared as soon as you call an async function :s
<andrewrk> not quite
<companion_cube> (in rust, it's quite clear what's shared or not)
<companion_cube> ah?
<andrewrk> when you create an API one of the decisions you make is whether or not it is thread safe
THFKA4 has joined #zig
<andrewrk> e.g. std.HashMap
<companion_cube> right, but can you control whether a complicated piece of code always runs on a single thread?
<andrewrk> well, for one you could choose to initialize the event loop with a single thread. but let's say that you're a library, not in control of the i/o mode
<andrewrk> your library defines an API that is or is not thread safe. If it's not thread safe, that's perfectly fine, it's the caller's responsibility to lock/data protect
<andrewrk> internally, now, you're going to call functions that might be async functions
<andrewrk> let's say that you never use `async`. in this case all accesses to your data will be always from one concurrent thread. not necessarily the same one the whole time, but only 1 at a time
<andrewrk> sort of like how the kernel can pre-empt and then resume in another cpu core
<companion_cube> ah, I think I see
<companion_cube> in this way `async` is a bit like `go` in go
<companion_cube> or spawn, or whatever
<andrewrk> yes it is
<companion_cube> alright, that makes more sense, thank you.
<andrewrk> if you use `async`, then you've now invited the possibility of > 1 concurrent thing
<companion_cube> in the scope of the async, yes
<companion_cube> (I mean, for values shared with teh async expr)
<companion_cube> that's reasonable indeed.
<andrewrk> however, the application may choose blocking I/O, in which case your `async` calls are actually just blocking, and await is noop
<companion_cube> shouldn't you still have a trhead pool or something?
<andrewrk> the std lib event loop has a thread pool
<companion_cube> this seems like it'd invite deadlocks, if you rely on the `async` running in parallel
<companion_cube> I mean when it's blocking IO
<andrewrk> it's correct that it's possible to write code that depends on non-blocking I/O. the chat server demo in the live stream is an example of this
<andrewrk> it's also possible to comptime assert that the io mode is non-blocking, so you can prevent a runtime deadlock of this nature
<emekankurumeh[m]> have we tested zig on more exotic llvm targets? like nvptx or amdggpu?
<companion_cube> right, comptime assert, gotcha
<andrewrk> but, importantly, for some libraries, there is no reason for them to have to choose; the logic is perfectly fine for both non-blocking and blocking
<andrewrk> emekankurumeh[m], not in any meaningful way
<companion_cube> it seems pretty hard to write something optimal in both cases, though
<companion_cube> (like, if you use async to run a few queries in parallel and use the first one that completes; in sync mode it's just a waste)
<andrewrk> companion_cube, check this out! https://github.com/andrewrk/zig-async-demo/tree/master/factorial
<andrewrk> don't get distracted by perf comparison, the point is the fact-await.zig example
<andrewrk> and the explanation of that example at the bottom
<companion_cube> (I'd be curious to know how it compares with crystal)
return0e_ has quit []
<andrewrk> Kappa322, tests passed. pushing to master. addIncludeDir will now do -I instead of -isystem
<mq32> my promised two bug reports had a child and got three! *grin*
<Kappa322> andrewrk, cheers! Rebuilding now to try it out
kllr_sbstn has quit [Remote host closed the connection]
<mq32> +1 bug
<dimenus> andrewrk: thanks for the vector-element-access merge!
Akuli has quit [Quit: Leaving]
<andrewrk> dimenus, np, thanks for being a guinea pig on this simd stuff
kllr_sbstn has joined #zig
<andrewrk> dimenus, what's the next simd blocker issue?
<dimenus> on my side? hmm gather/scatter or bitcasting probably
<andrewrk> yeah on your side. thanks good to know
doublex_ has quit [Ping timeout: 268 seconds]
doublex has joined #zig
bjorob has joined #zig
<leeward> Is there a way to create an array of known size that aliases part of another fixed-size array?
<mq32> leeward, do you have a reason not to use a slice?
<leeward> mq32: Maybe not. Assuming slices can use their comptime-known lengths to minimize overhead at runtime.
<mq32> what are you coding that unrolling a loop is necessary?
<mq32> D:
<mq32> because otherwise slices aren't slower than arrays
<leeward> Who's unrolling loops?
<mq32> a slice is just "pointer+length"
<leeward> Right, I'm not concerned about speed; I'm concerned about space.
<leeward> 1K of RAM makes one stingy.
<mq32> as long as you only use slices on the stack, it should be fine
<mq32> otherwise, if you really care for size, you could probably just pointer-cast stuff
<leeward> These are global.
<mq32> so where's the problem? you can iterate with an offset then
<leeward> I have a bunch of memory, which is a big array, but also want smaller arrays that point into it.
<leeward> No loops involved, at least not yet.
<mq32> huh
<mq32> can you tell me what you want to build?
<mq32> it's better to reason about stuff if you have context
ltriant has joined #zig
<leeward> It's an emulator. The goal is to ultimately run it on a similar-but-different piece of hardware.
<leeward> The global memory space is an array, and there are some memory-mapped registers in it.
<leeward> So addrSpace[32..96] is a set of registers.
<mq32> are the registers "smart" or "dumb"?
<mq32> because if you're writing an emulator, you should probably use setMem and getMem functions then (to implement memory mapped i/o)
<leeward> It varies. Some are just plain general purpose registers. Others trigger things happening when written to, but can be read.
<mq32> yeah then i recommend setMem/getMem
<mq32> but: i have to get some sleep, i'm getting grumpy
<leeward> Yeah, that's probably the easiest way to do it.
<leeward> Enjoy.
clktmr has joined #zig
doublex has quit [Ping timeout: 240 seconds]
doublex has joined #zig
<FireFox317> andrewrk: With the new boot files I'm pretty sure it is necesarry to name the binary kernel8.img instead of kernel7.img
wootehfoot has quit [Read error: Connection reset by peer]
dantix has quit [Quit: Bye]
FireFox317 has quit [Ping timeout: 240 seconds]
Kappa322 has quit [Remote host closed the connection]
ltriant has quit [Ping timeout: 240 seconds]
clktmr has quit [Ping timeout: 246 seconds]
kllr_sbstn has quit [Ping timeout: 268 seconds]
kllr_sbstn has joined #zig
ltriant has joined #zig
clktmr has joined #zig
clktmr has quit [Ping timeout: 240 seconds]