ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
return0e has quit [Ping timeout: 260 seconds]
return0e has joined #zig
tiehuis has joined #zig
<wink_>
andrewrk: nice demo!
kristate has joined #zig
<kristate>
back online
return0e has quit [Ping timeout: 268 seconds]
return0e has joined #zig
qazo has joined #zig
qazo has quit [Ping timeout: 244 seconds]
kristate has quit [Read error: Connection reset by peer]
kristate has joined #zig
qazo has joined #zig
qazo has quit [Ping timeout: 244 seconds]
qazo has joined #zig
qazo has quit [Ping timeout: 248 seconds]
<kristate>
andrewrk: online?
<andrewrk>
hi kristate
<andrewrk>
I have a few minutes before bed
<kristate>
andrewrk: hi -- about to push async UDP
<kristate>
I am basing it off your async-fs branch
<andrewrk>
interesting
<andrewrk>
linux?
<kristate>
posix -- testing on mac
<kristate>
porting to windows shouldn't be too hard.
<kristate>
andrewrk: oh, I wanted to know -- is there a way to initialize structs without filling out all elements?
<andrewrk>
you can set the whole thing to undefined, and then initialize some elements
<kristate>
andrewrk: I'm initing some sockaddr structs and on macos len is required
<andrewrk>
kristate, you can base the PR on the branch in github and then it will make the diff easier to see, and make the merge button merge it into the correct branch
<kristate>
andrewrk: okay, let me check
<andrewrk>
it's no big deal, I'm looking at only your commits anyway
<kristate>
andrewrk: still need to consolidate net.Address some more. Also, there is huge overlap in some of the posix defines
<kristate>
yeah, if you can push through that I can knock down more of the networking library
<kristate>
also, I am thinking about writing a net buffer like object, but does one exist?
<andrewrk>
would you be up for doing some of the file system stuff for macos? (the PR I have in progress)
<andrewrk>
that would help me merge that sooner
<andrewrk>
and I can start on the windows stuff
<kristate>
andrewrk: yeah, I can work through that
<kristate>
okay, let me cherry-pick some of these fixes to darwin and then I will make a async-fs-darwin branch
<andrewrk>
the PR looks good so far
<kristate>
andrewrk: what should I use as a test bench for async-fs?
<andrewrk>
you can add more tests to std/event/fs.zig or you can add std/event/fs_test.zig
<andrewrk>
I think the test I have in std/event/fs.zig hits all the APIs
<kristate>
andrewrk: okay, cool -- I am replying to your comment
<andrewrk>
kristate, I think it's good you followed the API pattern from std.event.fs.Watch for UDP. I think it's going to be nice, having the packets come from a Channel
<andrewrk>
I think we should also update the tcp code that is currently there to have this API
<kristate>
andrewrk: I agree
<andrewrk>
also feel free to stick with networking code if that's what interests you! I just wanted to give you a suggestion if you were looking for something to do
ofelas has quit [Quit: Yaaic - Yet another Android IRC client - http://www.yaaic.org]
kristate has quit [Ping timeout: 276 seconds]
davr0s has joined #zig
return0e_ has joined #zig
return0e has quit [Ping timeout: 248 seconds]
return0e has joined #zig
return0e_ has quit [Ping timeout: 260 seconds]
bheads has quit [Remote host closed the connection]
ofelas has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
ofelas has quit [Quit: Yaaic - Yet another Android IRC client - http://www.yaaic.org]
qazo has joined #zig
qazo has quit [Ping timeout: 244 seconds]
<unique_id>
andrewrk: "after I clean this up a bit, I'm going to look into hot code swapping" - that's awesome! It's going to be exciting to see if that's feasable and what can be done with it.
MajorLag has joined #zig
kristate has joined #zig
<kristate>
back online
zolk3ri has quit [Quit: leaving]
zolk3ri has joined #zig
ofelas has joined #zig
zolk3ri has quit [Client Quit]
zolk3ri has joined #zig
zolk3ri has quit [Client Quit]
zolk3ri has joined #zig
zolk3ri has quit [Client Quit]
zolk3ri has joined #zig
ofelas has quit [Quit: Yaaic - Yet another Android IRC client - http://www.yaaic.org]
zolk3ri has quit [Quit: leaving]
zolk3ri has joined #zig
return0e has quit [Read error: Connection reset by peer]
kristate has quit [Remote host closed the connection]
return0e has joined #zig
kristate has joined #zig
kristate has quit [Remote host closed the connection]
<wink_>
I'm looking for a way for two threads to communicate, specifically if there are no messages on a queue I want a thread to wait until there are messages. A way to do this is with a condition variable and a mutex but I don't see either, did I miss it?
davr0s has joined #zig
zolk3ri has quit [Quit: Lost terminal]
qazo has joined #zig
zolk3ri has joined #zig
zolk3ri has quit [Client Quit]
zolk3ri has joined #zig
qazo has quit [Ping timeout: 244 seconds]
zolk3ri has quit [Client Quit]
zolk3ri has joined #zig
qazo has joined #zig
qazo has quit [Ping timeout: 248 seconds]
MajorLag has quit [Ping timeout: 265 seconds]
MajorLag has joined #zig
kristate has joined #zig
kristate has quit [Remote host closed the connection]
kammd[m] has quit [Ping timeout: 240 seconds]
meena has quit [Ping timeout: 256 seconds]
meena has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
very-mediocre has joined #zig
lqd_ has joined #zig
bodie_ has quit [Ping timeout: 240 seconds]
lqd has quit [Ping timeout: 256 seconds]
lqd_ is now known as lqd
atk has quit [Ping timeout: 256 seconds]
meena has quit [Ping timeout: 256 seconds]
meena has joined #zig
bodie_ has joined #zig
atk has joined #zig
davr0s has joined #zig
very-mediocre has quit [Quit: Page closed]
v1zix has joined #zig
<Dirkson>
Arrays in zig have an array.len property. Is that the only array.whatever thing they have? How should I refer to the .whatever portion?
<Dirkson>
Mmm. "Field", maybe.
<Dirkson>
Currently, zig appears to error when I try to use tab-based indentation. I'm a hardcore tab-ite - Is there any way to browbeat zig into accepting tab-based indentation? Why does it even care that I use tabs?
<MajorLag>
As far as I am aware, arrays only have the one magical comptime field.
<Dirkson>
If you want to go this way then the compiler should have an option to automatically rewrite source files that contain tabs to spaces so that people can still use ziglang without having to switch their editing software.
<Dirkson>
That's coming soon. We have zig fmt in the self-hosted compiler, and it's planned to support hard tabs."
<Dirkson>
That's annoying, but tolerable. Nim was the same way. I find the space-based indenting crazy completely nonsensical, but computer professionals stubbornly keep refusing to consult me on this before implementing things.
<Dirkson>
MajorLag: But thanks! That bit does address the tab thingie.
<MajorLag>
It comes up pretty frequently.
v1zix has quit [Quit: Page closed]
zolk3ri has quit [Quit: leaving]
zolk3ri has joined #zig
MajorLag has quit [Ping timeout: 245 seconds]
return0e_ has joined #zig
return0e has quit [Ping timeout: 260 seconds]
<Dirkson>
Since zig code is utf-8, and string literals are type u8 and part of zig code, that means that SomeStringLiteral[17] is not neccesarily the (17+1)th character of SomeStringLiteral, correct?
<andrewrk>
Dirkson, string literals are just byte arrays
<Dirkson>
Coolcool.
<andrewrk>
in my experience, nearly every program and library can be correct by never decoding utf-8
<Dirkson>
Mine too, I just wanted to be sure that what I thought should be happening was actually what was happening :D
<Dirkson>
So the error handling system appears to be designed around the idea of bubbling the error up through numerous functions. That's frequently a thing I want to do, but usually when I want to do it, I'm quite keen on putting that error in front of the user's face at some point in some format they can understand. Does the error system help with this task at all?
<andrewrk>
switching on an error is useful since the compiler makes sure you handle the correct set
<andrewrk>
you can do this to print user friendly messages
<andrewrk>
you can use the @errorName builtin function as a shortcut
<andrewrk>
also errors are supported in the print functions
MajorLag has joined #zig
<Dirkson>
Awesome.
<andrewrk>
if and while support destructuring error unions
<andrewrk>
if (foo()) |ok_value| {...} else |err| {...}
<andrewrk>
catch gives you the error
<andrewrk>
foo() catch |err| { ... }
<Dirkson>
One of my Side Projects is writing @errorName for vulkan. Which is a ROYAL PITA for C, particularly when you're trying to do it after-the-fact for someone else's library.
<Dirkson>
Zig appears to have a standard library, but I haven't found documentation for it yet. Is that a thing?
geocar has quit [Quit: Connection closed for inactivity]
<Dirkson>
Not yet. I avoided it with my usual dislike of technical concepts in video-form, but I'll take a look if it's important :D
<Dirkson>
I am pretty majorly impressed that it only rebuilds the function that changed.
<andrewrk>
oh yeah, you're like me. don't worry after I polish it up I'll write about it in text form
<andrewrk>
I think my longer streams won't be for you but if I do a 1 minute demo, those should be interesting
<Dirkson>
Yah, agreed. This one was pretty cool.
<andrewrk>
I also realized that it shouldn't even be saying "build succeeded" when nothing changes
<andrewrk>
because there's no reason to even relink and no reason to emit a message at all. we read the file, notice nothing changed, and then discard it
<Dirkson>
That seems reasonable to me.
<Dirkson>
You might want to have a switch to enable the current behavior though, to assist with debugging the language.
<andrewrk>
sure. I might invert it though :D - `--build-only-once`
<andrewrk>
rather than `--watch`
<Dirkson>
My aversion got markedly worse after switching to my current "day job", which is making a game in Unity. Roughly half the plugins I buy are only documented in video form. There's a reason I'm currently procrastinating by learning Zig.
<Dirkson>
I could see common workflows where rebuilding constantly wouldn't be ideal. Shucks, anything larger than a few hundred lines and I stop wanting 'build automatically' to be the default. Although then I've usually made a build script to automate all the build weirdness.
<andrewrk>
why wouldn't you want that? it only rebuilds what you change
<andrewrk>
especially when you have a large project, you would want this
<Dirkson>
A lot of the time with a large project, I need to make several changes in several unrelated files before something compilable results. When it watches and tries to build things I know will result in errors, it both gnaws up system resources uselessly and throws error messages that I already know about at me.
<Dirkson>
Also, I have a habit of saving whenever I pause typing. Helps reduce the impact of crashes and/or forgetful dirksons. This results in a lot of saves while I'm im the middle of writing some function or another, which also won't neccesarily be compilable.
<Dirkson>
I don't know how common either of these behaviors are outside of me, though.
<andrewrk>
I also save when I pause typing
<andrewrk>
when you're coding though, don't you have free resources? and it's nice to know the status - that there are compile errors - and then you watch them go away when everything's done
<andrewrk>
that's one thing that IDEs do nicely - red squigglies of the errors while you're coding
<andrewrk>
and maybe you hit save and you didn't expect something to break, then it's good to know an error happened
<Dirkson>
There *is* a point that, since you can compile each function independently, you can actually make forward progress compiling as I save. (Which is less likely to be true of, say, C, where it'll keep recompiling the whole compilation unit each time) And usually I have plenty of spare resources, that's true. (Unless it's summer and I begrudge every unit of heat my computer outputs :D ) I do enjoy the red squiggles
<Dirkson>
when I can make them work.
<andrewrk>
you can imagine that an IDE hooking into this setup is much more efficient
<andrewrk>
for your summer days
<Dirkson>
Hah, fair.
<Dirkson>
Yeah, ok. I'm not sure I can come up with any more reasonable objections. You're winning me over to team "Just make the build system continuously do its thing"
<Dirkson>
Doing it continuously means you can skip some steps, actually. Don't have to scrape the build instructions up off the disk every single time you build. You know exactly which files have changed, so you don't have to look at every single file mentioned by the build system every time it runs. Etc. Maybe those aren't worth chasing, but they're at least available.
<andrewrk>
it's pretty optimal. even if you want to manually trigger it, you can have a little shell prompt there:
<andrewrk>
zig> rebuild
<andrewrk>
and it will do a minimal rebuild with only the stuff that changed since last time
<Dirkson>
That's not a bad idea either.
<andrewrk>
I hope your imagination is going wild with all the other commands this prompt could have
<andrewrk>
since it has full introspection into the compilation state
<Dirkson>
That did immediately spring to mind :D
<andrewrk>
zig> rename std.foo.blah newName
<Dirkson>
... Yes.
MajorLag has joined #zig
<Dirkson>
Oh, I wanted to ask- There are a lot of @typeaToTypeb() builtin functions. Is there some reason that they couldn't be replaced by a @cast(fromType, toType, Castable) function?
<andrewrk>
we used to have syntax for that - if you invoked a type as a function
<Dirkson>
Oh, that was the other way I was going to suggest. Why 'used to'?
<andrewrk>
the explicitness is now intentional
<andrewrk>
so that you're likely to get a compile error if you change the types of something
<andrewrk>
rather than now accidentally coercing this new type to some other type
<andrewrk>
I can explain more later but I gotta run, ttyl
<Dirkson>
See you!
MajorLag has quit [Ping timeout: 276 seconds]
<Dirkson>
That's actually why I decided to suggest the "@cast(fromType, toType, Castable)" format instead of the type-function format. It maintains the explicitness, while simplifying the syntax. (While the type-function method simplifies the syntax by *removing* the explicitness)
qazo has joined #zig
qazo has quit [Ping timeout: 244 seconds]
MajorLag has joined #zig
qazo has joined #zig
MajorLag has quit [Ping timeout: 265 seconds]
<unique_id>
I save way, way too much. Like an fps player that reloads after every peek-and-shoot.
qazo has quit [Ping timeout: 248 seconds]
<unique_id>
How do I create a 0 length slice pointing to nothing?
<unique_id>
I did it with a cast and [0..0] syntax
<unique_id>
I know that if a function needs a struct but does not need to modify it, it should take it by value (and Zig will figure out how best to pass it in). But, in the caller if I need to reference the struct multiple times I might do: "const the_struct = something.something.the_struct;" but I don't want excessive copies, so I'll do "constr the_struct = &...;". Now I'm in a pickle because I need an ugly dereference to call the function:
<unique_id>
"foo(the_struct.*)".
<unique_id>
Do I: 1) make the function take *const TheStruct, or 2) do the dereference when calling the function, or 3) do "const the_struct = ...;" which at least appears to make a copy?
<unique_id>
So the problem is that if I'm already handling the struct through a pointer to const because the struct is large, then making functions accept the struct by-value (to be optimized however Zig likes) breaks the consistency.
<unique_id>
brb in 8 hours :)
return0e_ has quit [Read error: Connection reset by peer]
return0e has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]