<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
<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
<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>
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]
<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
<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
<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 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)