ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
<forgot-password> I'm using @memberName
<forgot-password> Or can I just append c""?
<daurnimator> `++ c""` should work actually
<forgot-password> Hm, sadly it did not. Does c"" get optmized away?
<daurnimator> andrewrk: is there a way to specify the field that contains the type for an enum?
<daurnimator> s/enum/union/
<daurnimator> I'm looking at our sockaddr definitions.... they don't seem right
<daurnimator> andrewrk: I'm thinking e.g. you could provide some 'special' method on a extern union?
<daurnimator> `sockaddr_storage = extern union { in: sockaddr_in, in6: sockaddr_in6, fn @unionEnum(self: sockaddr_storage) sa_family_t { return @intToEnum(sa_family_t, self.in.family) } }`
<daurnimator> (yes I know sa_family_t is not currently an enum; but it probably should be a packed enum?)
steveno has joined #zig
return0e has joined #zig
return0e_ has quit [Ping timeout: 246 seconds]
steveno has quit [Ping timeout: 260 seconds]
oats has left #zig ["WeeChat 2.3"]
forgot-password has quit [Ping timeout: 272 seconds]
forgot-password has joined #zig
forgot-password has quit [Ping timeout: 244 seconds]
forgot-password has joined #zig
hooo has quit [Quit: Connection closed for inactivity]
return0e has quit [Read error: Connection reset by peer]
return0e_ has joined #zig
Ichorio_ has joined #zig
Ichorio has quit [Ping timeout: 258 seconds]
emekoi has joined #zig
<emekoi> does zig link to libunwind?
<emekoi> because the repo includes a copy of the headers.
forgot-password has quit [Ping timeout: 240 seconds]
emekoi has quit [Remote host closed the connection]
emekoi has joined #zig
_whitelogger has joined #zig
<andrewrk> emekoi, no it doesn't. where do you see that?
<emekoi> never mind, it's just the header unwind.h in c_headers.
_whitelogger has joined #zig
MajorLag has joined #zig
emekoi has quit [Ping timeout: 258 seconds]
daurnimator has quit [Ping timeout: 268 seconds]
daurnimator has joined #zig
_whitelogger has joined #zig
_whitelogger has joined #zig
MajorLag has quit [Ping timeout: 264 seconds]
MajorLag has joined #zig
Zaab1t has joined #zig
return0e has joined #zig
return0e_ has quit [Read error: Connection reset by peer]
Ichorio_ has quit [Ping timeout: 246 seconds]
MajorLag has quit [Ping timeout: 264 seconds]
MajorLag has joined #zig
forgot-password has joined #zig
forgot-password has quit [Ping timeout: 244 seconds]
return0e has quit [Ping timeout: 246 seconds]
return0e has joined #zig
forgot-password has joined #zig
<forgot-password> ilcear
forgot-password has quit [Quit: Lost terminal]
forgot-password has joined #zig
<forgot-password> Is it possible to have a comptime value that I can manipulate at runtime? In my current attempt the compiler says 'cannot store runtime value in comptime variable'
j`ey has left #zig [#zig]
Pursche01 has joined #zig
forgot-password has quit [Quit: Lost terminal]
forgot-password has joined #zig
<Pursche01> Hi, I just found out about Zig 30 minutes ago and I have been digging through the documenation a bit. It looks like an interesting language and I think I would like to give it a try. Before I do though, there is a concept I haven't found in the documentation. Does Zig have "pure" functions? Can I at compiletime force a function not to have side effects and not access non-const global scope?
<Pursche01> Alternatively are there any good tools for parsing Zig (preferably from Zig rather than from C), building an AST and figuring out "pureness" from a custom built pre-compiler?
<forgot-password> I'd love to have something like this too (I'm refering to the pure functions)
return0e has quit []
Ichorio has joined #zig
hooo has joined #zig
<MajorLag> the standard library has a zig parser in it
<forgot-password> Is it possible to do something along the lines of this: https://pastebin.com/5F0HyMKt?
<forgot-password> It already feels like fighting the language, but I'd love to know if it is plausible.
return0e has joined #zig
<MajorLag> the problem with what you've written is that someFunction's first parameter needs to be FirstStruct, but you've passed it SecondStruct. `second.someFunction()` is equivelent to `SecondStruct.someFunction(second)`. There is an implementation of interfaces in std that does what I think you're trying to do, however we're planning to move away from it because it doesn't optimize well. see: https://github.com/ziglang/zi
<MajorLag> interface pattern can be seen in `std.mem` and `std.heap` where it is used with Allocator and its implementations.
<MajorLag> Bascially the interface struct instance lives as a member of the parent struct and itself contains function pointers to the implementations in the parent, but those parent functions take a pointer to the interface struct and use @fieldParentPtr to get their own instance from that instance.
<MajorLag> Something like this: https://pastebin.com/P3Y8VrWV
<forgot-password> MajorLag: Thanks, I think you messed up your link in the first message
<MajorLag> worked fine for me?
<forgot-password> It looks like the message was cut off, maybe my irc client has a limit on message length.
<MajorLag> this was all that was after the link: The current interface pattern can be seen in `std.mem` and `std.heap` where it is used with Allocator and its implementations.
<forgot-password> What? How is that, it's displayed as a separate message for me picking up at " interface pattern[...]" again
<MajorLag> Your client might not like colons? What does: this look like?
<forgot-password> Heh, weird https://i.imgur.com/xpkkl4h.png
<forgot-password> It looks fine
<MajorLag> huh. weird
<forgot-password> I'm going to put together a little write-up of what I'm currently trying to do. I feel like I'm too focused on the current approach, so maybe anybody has an idea for a different implementation.
MajorLag has quit [Ping timeout: 260 seconds]
MajorLag has joined #zig
<Pursche01> @MajorLag: Do you think the standard library parser will be able to figure out if something has side effects?
<andrewrk> Pursche01, no, it just parses into an abstract syntax tree
<forgot-password> Pursche01: I suppose you could just (heh, "just") walk through the AST and check whether it does something that would classify it as having side effects. However, neither does that sound like a small undertaking nor do I know about the parser. So don't take my word for granted :p
<andrewrk> we used to have the concept of implicit pure functions
<forgot-password> Phew, I finally finished my small write-up: https://gist.github.com/schroffl/17150efeedf18f5ca3ef3a724344f247
<andrewrk> and if a function call had all comptime known arguments and was pure, then the function would be interpreted at compile time automatically
<andrewrk> Pursche01, the closest issue we have open to your question is https://github.com/ziglang/zig/issues/425. you are also welcome to open a proposal with your purity feature
<andrewrk> relevant to #425, it's possible that "pure" and "wanting to be comptime if possible" are the same thing
<forgot-password> andrewrk: So you ditched that for comptime expressions?
<andrewrk> I can't remember why I changed that. there are a few things to solve if we wanted to reintroduce it
Zaab1t has quit [Quit: bye bye friends]
steveno has joined #zig
fsateler has joined #zig
fsateler_ has quit [Ping timeout: 246 seconds]
Thalheim has quit [Quit: brb]
allan0 has quit [Ping timeout: 250 seconds]
steveno has quit [Ping timeout: 250 seconds]
THFKA4 has quit [Ping timeout: 252 seconds]
forgot-p1ssword has joined #zig
forgot-password has quit [Quit: Lost terminal]
Pursche01 has quit [Quit: Connection closed for inactivity]
steveno has joined #zig
steveno_ has joined #zig
steveno has quit [Ping timeout: 250 seconds]
steveno_ has quit [Remote host closed the connection]
Ichorio has quit [Ping timeout: 258 seconds]
forgot-p1ssword has quit [Quit: leaving]
forgot-password has joined #zig
steveno has joined #zig
steveno has quit [Remote host closed the connection]
forgot-password has quit [Quit: leaving]