ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
fsateler has quit [Read error: Connection reset by peer]
fsateler has joined #zig
_whitelogger has joined #zig
steveno has joined #zig
steveno has quit [Quit: Leaving]
darithorn has quit [Quit: Leaving]
kristate has quit [Remote host closed the connection]
kristate has joined #zig
<daurnimator> zig translate-c doesn't seem to support anonymous unions
kristate has quit [Ping timeout: 246 seconds]
kristate has joined #zig
kristate has quit [Remote host closed the connection]
kristate has joined #zig
kristate has quit [Remote host closed the connection]
kristate has joined #zig
kristate has quit [Remote host closed the connection]
kristate has joined #zig
kristate has quit [Remote host closed the connection]
kristate has joined #zig
scriptnull has joined #zig
kristate has quit [Ping timeout: 250 seconds]
kristate has joined #zig
marmotini_ has joined #zig
_whitelogger has joined #zig
Zaab1t has joined #zig
scriptnull has left #zig [#zig]
kristate has quit [Ping timeout: 250 seconds]
kristate has joined #zig
kristate has quit [Ping timeout: 245 seconds]
kristate has joined #zig
kristate has quit [Remote host closed the connection]
kristate has joined #zig
marmotini_ has quit [Ping timeout: 246 seconds]
marmotini_ has joined #zig
Zaab1t has quit [Ping timeout: 272 seconds]
Zaab1t has joined #zig
kristate has quit [Remote host closed the connection]
kristate has joined #zig
fsateler has quit [Read error: Connection reset by peer]
fsateler has joined #zig
meheleventyone has joined #zig
pqflx3[m] has joined #zig
meheleventyone has quit [Quit: Textual IRC Client: www.textualapp.com]
marmotini_ has quit [Ping timeout: 252 seconds]
steveno has joined #zig
steveno_ has joined #zig
steveno has quit [Ping timeout: 252 seconds]
hg has joined #zig
darithorn has joined #zig
marmotini_ has joined #zig
marmotini_ has quit [Ping timeout: 272 seconds]
return0e_ has quit [Ping timeout: 246 seconds]
<MajorLag> zig doesn't support anonymous unions. I ran into that relatively early on and andrew explained that technically ANSI C doesn't support anonymous unions.
<andrewrk> hm I don't remember that
<andrewrk> we support anonymous unions now, but syntax limitations prevent you from using them. this would fix it:
<andrewrk> oh, I was going to link to https://github.com/ziglang/zig/issues/1315 but that's a related, but different issue
<andrewrk> I think it would be the anonymous struct literal syntax that would also apply to unions
<andrewrk> I don't see any reason why translate-c cannot be improved to support C anonymous unions, at least after this issue is resolved
<MajorLag> I believe I was working with translating the Windows API at the time, which uses it extensively. Fortunately it turned out that MS supported ANSI C and it just needed a #define to name the unions.
<andrewrk> MajorLag, ah, I remember now. I think there are 2 concepts that are anonymous unions and you are referring to the one where the namespace is flattened
<MajorLag> Yes. Is that not what is meant? Is there a bug with simply declaring an unnamed union in other contexts?
<andrewrk> I was thinking about when there is no declaration name assigned to the type
<hg> ^ that's what I was thinking of too
<hg> and that's existed in C for a long time
<andrewrk> yeah, that should translate fine, and everything I said above applies to that
<hg> even moreso since C11 where an anonymous union is allowed inside another aggregate and kind of seamlessly behaves as though its members are directly part of the encompassing aggregate
<andrewrk> ^ that's the thing zig does not support
<andrewrk> I believe there are open proposals to add this, but I haven't given it serious consideration yet
<hg> I mean
<MajorLag> Zig could support automatically naming them in the same way the #define on Windows headers does. I believe it just uses s0,s1,u0,u1, etc.
<andrewrk> MajorLag, you're talking about for the purposes of translate-c?
<hg> the benefit of anonymous aggregate submembers is mostly that it allows for C to have a simpler way of doing a tagged union (i.e., like the Maybe type in Haskell)
<hg> not sure that really applies to Zig as useful since Zig already has a lot of those benefits
<MajorLag> andrewrk, yes.
<hg> 🤷
<andrewrk> MajorLag, I think that makes sense
<MajorLag> also, sorry about not getting back to you yet on 1885. Looking at that today (ideally...).
<andrewrk> today will be a good day if I get all the std lib tests passing in the copy elision branch
<hg> :D
<andrewrk> I'm really glad I did this work in stage1. when I implement this in stage2, I know how to do it much better
<hg> andrewrk: pardon my (perhaps, continued) ignorance; what do stage1 and stage2 refer to? self-hosting?
<andrewrk> stage1 is the zig compiler implementation written in C++
<andrewrk> stage2 is the self-hosted compiler
<andrewrk> stage3 is the self-hosted compiler, built with stage2
<andrewrk> see the readme for a more detailed explanation
<hg> right, cool :)
Ichorio has joined #zig
<andrewrk> the tests are in the middle of a transition: there will be a stage1 directory, stage2 directory, and a `both` directory. tests which only pass in stage1, tests which only pass in stage2, and tests which pass in both
<andrewrk> ideally all the tests would be in the `both` directory, but it's not going to be an immediate thing, so that's why there is an ongoing transition
<hg> sure
<MajorLag> I'm looking forward to seeing if I can clean up serialization by removing the `deserializeTo` method thanks to copy elision.
<andrewrk> MajorLag, deserializeInto?
<MajorLag> yeah, that one
<andrewrk> I think you would need "Part 2" of copy elision. When this branch is done, you get copy elision in your `return` expressions, but if you declare a variable and then return it, you'll get a copy
<MajorLag> Oh, yes, you're right. I'm jumping the gun there.
<andrewrk> this is the bulk of the work though. part 2 will be nowhere near as much of an implementation investment
<andrewrk> e.g. it would take 1 hour to add @getReturnPtr if we went that route
<MajorLag> sweet
<andrewrk> the other thing I want to explore after this branch is done, is ability to mark a struct or maybe even a field as unmovable, and you get a compile error if it would get memcpy'd
<MajorLag> That would be helpful. How would you override it, if necessary? My first thought is to use @intToPtr/@ptrToInt. It's ugly and hacky, but needing to copy an uncopiable field seems like a pretty deperate circumstance anyway.
<andrewrk> I think @memcpy would actually work. the compile error would happen for assignment or other expressions. essentially, any "hidden" memcpy
<andrewrk> (which is one reason coders are encouraged to use std.mem.copy when possible, since it would have the safety of a compile error if you try to copy an unmovable field)
<andrewrk> I realized that one mistake I made in this branch was trying to do the result location mechanism as well as destructuring of error unions and optionals. they're both large complicated changes, and doing them together multiplied the difficulty
<andrewrk> but hey, once this is done, even in functions that return an error, or an optional, you still get no-copy for the payload
marmotini_ has joined #zig
wootehfoot has joined #zig
steveno_ has quit [Ping timeout: 272 seconds]
steveno_ has joined #zig
return0e_ has joined #zig
marmotini_ has quit [Ping timeout: 250 seconds]
marmotini_ has joined #zig
marmotini_ has quit [Ping timeout: 245 seconds]
Zaab1t has quit [Quit: bye bye friends]
return0e_ has quit [Ping timeout: 246 seconds]
steveno__ has joined #zig
steveno_ has quit [Ping timeout: 250 seconds]
hg has quit [Quit: WeeChat 2.3]
<daurnimator> andrewrk: so how long now until copy ellision is merged?
wootehfoot has quit [Read error: Connection reset by peer]
return0e_ has joined #zig
return0e_ has quit [Remote host closed the connection]
steveno__ has quit [Ping timeout: 240 seconds]
return0e_ has joined #zig
Ichorio has quit [Ping timeout: 246 seconds]