ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
<andrewrk>
dbandstra2, the issue that intends to address this in a big way is well-defined copy elision
<andrewrk>
I think the proposal is stale, but bottom line is that your gist would actually work correctly
<dbandstra2>
what defines whether a value is considered copyable/non-copyable?
<dbandstra2>
currently you can return any struct... if in the future some structs (but not others) get the elision, or, some structs work and some cause a compile error, what is the criteria ? would the user write some explicit keyword in the struct definition?
davr0s has joined #zig
dbandstra2 has quit [Quit: Page closed]
dbandstra has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<GitHub77>
zig/master bbb565a Andrew Kelley: README: update support table...
kristate has quit [Remote host closed the connection]
kristate has joined #zig
<MajorLag1>
andrewrk, is there an issue for annotations?
<andrewrk>
MajorLag1, annotations of C code before translation? or of struct fields?
kristate has quit [Ping timeout: 264 seconds]
<MajorLag1>
struct fields, or possibly other things too.
cenomla has joined #zig
<andrewrk>
dbandstra, I don't have the answer to that stuff off the top of my head. I'll need to re-think that whole issue when I get back to it
<andrewrk>
MajorLag1, I don't think anyone created that proposal yet. would you like to do it?
<MajorLag1>
I might do it tomorrow. I ran into a case where I'd liked to have used it, so I'm probably in the frame of mind to articulate an argument for it.
<dbandstra>
andrewrk, no problem. hopefully as i get better immersed in the language i can be more constructive
IntoxicatedHippo has joined #zig
IntoxicatedHippo has quit [Quit: Leaving]
IntoxicatedHippo has joined #zig
<IntoxicatedHippo>
How would you design an API for a library that parses json directly in to structs? Possibly involving nested structs and arrays.
<tiehuis>
IntoxicatedHippo: I was thinking something simple like this https://clbin.com/whFYk
<tiehuis>
one more thing i didn't write there, but we could add json.Value as a field and delay parsing or allow parsing dynamic multi-typed arrays via that
<tiehuis>
otherwise, i'd just start of simple and handle the common cases first, omitting the more complex ideas mentioned
tiehuis has quit [Client Quit]
jjido has joined #zig
SimonNa has quit [Remote host closed the connection]
<GitHub175>
zig/master 212449b Marc Tiehuis: Fix Log2Int type construction...
davr0s has joined #zig
<Hejsil>
Why is it not possible to export function that take/return pointers to Zig auto layout structs?
clownpriest has joined #zig
SimonNa has quit [Quit: Leaving]
<MajorLag1>
Does anyone know, is there a reasoning behind forcing input buffers to be exactly equal to @sizeOf(T) when converting between bytes and types, instead of >= ? For instance: std.mem.readIntBE
rkeene has left #zig [#zig]
kristate has joined #zig
<GitHub138>
[zig] BraedonWooding opened pull request #1064: Add newline to zig fmt error (master...patch-4) https://git.io/vh0Eb
<andrewrk>
MajorLag1, that can be up for discussion. I reasoned that if the number didn't match exactly, it was probably a mistake
<andrewrk>
I'd be curious to see an example where that is not the case
<andrewrk>
kristate, why not have ChildProcess.exec start the event loop (scheduler) and use it, and then deinitialize it before returning?
<kristate>
andrewrk: Thanks for the reply/followup. (i) there could be a loop already running inside of the thread/instance and (ii) starting a new scheduler could be expensive
<kristate>
also, waiting on one scheduler while another is already running is the same as blocking
<andrewrk>
kristate, we'll definitely want to have a non-blocking API for child processes where you can use an already existing event loop
<andrewrk>
the blocking API might simply create an event loop and then call down to this one
<kristate>
andrewrk: that's why I thought it might be cool to piggy-back on the allocator since it seems to be tied to async already
<andrewrk>
can you elaborate? I don't see allocators as being tied to async
<andrewrk>
I would agree the other way around - async depends on allocators
<kristate>
andrewrk: that is my understanding, async depends on allocators
<andrewrk>
right, to create a coroutine requires an allocator
<kristate>
so when the coro is allocated, it could also register with an event loop that might be tied to the allocator
<andrewrk>
here's the thing though: coroutines as a language feature currently do not require an event loop
<andrewrk>
and an event loop can be created entirely in userland
<andrewrk>
wait, are you suggesting a userland change or a language change?
<kristate>
thanks for the good questions, I think more or less stdlib. I come from a C background and don't want to force loops on anyone. But, stdlib needs a loop
<andrewrk>
did you see std.event.Loop ?
<kristate>
I think the closest thing would be what apple did with objective-c, and possibly swift (but I haven't looked at swift)
<kristate>
yes, but there is no infra to get a global loop
<andrewrk>
but you can pass a loop as a parameter to anything that needs one
Ichorio has joined #zig
<andrewrk>
the same as if you are using libuv in C
<kristate>
I think that might be too much -- we already pass in the allocator
<andrewrk>
the event loop has an allocator field
<andrewrk>
so if you need an allocator and an event loop, you can accept only an event loop
<kristate>
right, could be possible to do a parent-whatever-you call it to get a pointer to the parent struct
<kristate>
but, in the case that such an allocator was not encased into an event struct, then what would happen? compiler error?
<andrewrk>
the async functions above actually don't need access to the event loop, but they would if they wanted to do other non-blocking stuff like networking or child process interaction
<kristate>
stdlib is really tough to make async without some sort of trait for event loops and then also finding that event loop
<MajorLag1>
andrewrk, I'm using it those functions to read/write struct fields from a file, in which case it is convenient to just pass `buffer[offset..]`. It isn't a big deal, I was curious because I'm looking at making a PR for some tweaks to std.mem and std.io to match their readInt/writeInt APIs, and fix an issue with writeInt not working on single bytes, and I was considering changing that assert.
<andrewrk>
the next thing I want to explore is multiplexing kernel threads onto coroutines
<andrewrk>
that would be a single runloop
<kristate>
andrewrk: generally, when is a good time for you? I am in Japan (GMT+9) and it's currently 0:21am
<andrewrk>
my day started 2 hours ago (GMT-5)
<kristate>
Cool -- is Zig full time for you at the moment?
<andrewrk>
it will be starting friday
<kristate>
awesome
<andrewrk>
I'm planning on making an announcement blog post to try to gain some momentum
<kristate>
As much as I have gotten into Rust, I still like programming C. With Zig, I really like how a lot of the power of LLVM is exposed in the builtins
<andrewrk>
yes, if a global variable is the right path
<andrewrk>
I think that we can make progress in the std lib even if we have to refactor it later
<andrewrk>
we can get networking going and then figure out how to restructure it
<kristate>
If you have time, it would be great to get a table outlining how much stdlib is complete -- that is, which parts are set in stone, and which parts are WIP
<kristate>
personally, I am thinking abou
<andrewrk>
good idea
<andrewrk>
in general, until 1.0.0 everything can potentially be changed
<kristate>
personally, I am thinking about taking the best of std and starting over
<andrewrk>
we have no stability yet
<kristate>
I like how there is no reliance on libc
<andrewrk>
std largely exists as a way to test out the language, until the language is stable
<kristate>
and I see that you have lots of syscalls
<nc-x[m]>
How will I go about converting [1]u8 to []u8 ?
<andrewrk>
nc-x[m], array[0..]
<nc-x[m]>
Sorry my question was vague. How do I convert "abc" to []u8 directly in a function call. Using the above syntax I get a []const u8 :(
<nc-x[m]>
To workaround, I am currently first saving it to a variable and then converting it
<andrewrk>
nc-x[m], in zig you have to always be able to answer the question, "where is the memory?"
<andrewrk>
the answer for string literals is, it's in the global constant .data section
<andrewrk>
you cannot mutate string literals, so taking a reference to them gives you a []const u8
<andrewrk>
if you want a mutable slice, you have to answer the question of "where is the memory?"
<nc-x[m]>
So I have to always first save them in a variable before converting them? No other workaround?
<andrewrk>
if you save an array in a local variable of a function, you are answering the question with "the memory will be in the stack frame of this function". if that answer is acceptable then that is the best place to put the memory
<andrewrk>
another place is globally, if that makes sense. otherwise you will have to heap-allocate and then be sure to free the memory when done
kristate has quit [Remote host closed the connection]
kristate has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
<GitHub105>
[zig] isaachier opened pull request #1065: Fix const-ness of buffer in replaceContents method (master...const-buffer-replace-fix) https://git.io/vh0dS
noonien has quit [Quit: Connection closed for inactivity]
Dodo has joined #zig
<Dodo>
hi!
btbytes has joined #zig
<Dodo>
can I use const Iterators yet? ;p
<andrewrk>
Dodo, what do you mean?
<GitHub172>
[zig] andrewrk closed pull request #1065: Fix const-ness of buffer in replaceContents method (master...const-buffer-replace-fix) https://git.io/vh0dS