ChanServ changed the topic of #zig to: zig programming language | https://ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
iocat has quit [Remote host closed the connection]
<daurnimator> https://finnoleary.net/kernel-code.html <== example of a syscall returning an undocumented error condition
iocat has joined #zig
<pixelherodev> "@panic(std.fmt.allocPrint(allocator, "Error parsing value: {}!\n", err) catch @panic("OOM"));" heh
wootehfoot has quit [Ping timeout: 240 seconds]
wootehfoot has joined #zig
<pixelherodev> ... oddly enough, that results in Zig segfaulting
<pixelherodev> The compiler, not my code
<pixelherodev> I can't imagine why
<pixelherodev> /s
<pixelherodev> Huh... actually, it's segfaulting if I have an open-ended else clause for the error handling *at all*
<pixelherodev> Or at least, a panic under any circumstances in such a clause
iocat has quit [Ping timeout: 260 seconds]
kristoff_it has quit [Ping timeout: 240 seconds]
_Vi has quit [Ping timeout: 252 seconds]
wootehfoot has quit [Quit: Leaving]
frmdstryr has joined #zig
lunamn has quit [Ping timeout: 250 seconds]
lunamn_ has joined #zig
nephele has quit [Ping timeout: 250 seconds]
nephele has joined #zig
_whitelogger has joined #zig
muffindrake has quit [Ping timeout: 250 seconds]
muffindrake has joined #zig
return0e has quit [Ping timeout: 240 seconds]
return0e has joined #zig
rjtobin has quit [Quit: Leaving]
<pixelherodev> Strings work!
<pixelherodev> I don't need stupid comptime asm workarounds anymore
<pixelherodev> `a3x.Puts("Hello, world!\n");` works :D
<pixelherodev> Here's another fun screenshot: https://i.imgur.com/COUaWA0.png
iocat has joined #zig
<pixelherodev> daurnimator, did the mixin streams get merged upstream yet?
<daurnimator> pixelherodev: nope.
<daurnimator> haven't even sent that PR... still waiting for andrew to merge the Random mixin one
<pixelherodev> That's what I figured
<pixelherodev> On the topic of mixins
<pixelherodev> What's the correct way to say "a parameter of type mixinbase"?
<pixelherodev> e.g. if three structures A B and C mix in D
<pixelherodev> Is there a way to have a single pointer type the can point to all of them?
<pixelherodev> Or does it have to be of type var?
mahmudov has quit [Ping timeout: 276 seconds]
frmdstryr has quit [Ping timeout: 240 seconds]
WendigoJaeger has quit [Ping timeout: 240 seconds]
<daurnimator> pixelherodev: it has to be of type `var`
<daurnimator> pixelherodev: though I hope https://github.com/ziglang/zig/issues/1669#issuecomment-481531875 gets accepted
<daurnimator> pixelherodev: that way we can have a `hasMixin(MyMixin)` or similar
<pixelherodev> That's what I"m hoping too
<pixelherodev> I'm*
return0e_ has joined #zig
return0e has quit [Ping timeout: 240 seconds]
<pixelherodev> The fact that I can actually read this is astounding: `if (context.scope.list.at(blockindex).Variable.value.BasicBlock == self) `
<pixelherodev> A buuuunch of nested structs / tagged unions / an array list :P
<pixelherodev> Another nice thing about Zig is that you can safely delete `self`/`this` since it's just another variable :)
return0e_ has quit [Read error: Connection reset by peer]
return0e has joined #zig
iocat has quit [Ping timeout: 260 seconds]
traviss has quit [Remote host closed the connection]
_whitelogger has joined #zig
return0e has quit [Read error: Connection reset by peer]
return0e has joined #zig
FireFox317 has joined #zig
FireFox317 has quit [Remote host closed the connection]
_whitelogger has joined #zig
benjif has joined #zig
traviss has joined #zig
_whitelogger has joined #zig
darithorn has quit [Quit: Leaving]
mahmudov has joined #zig
wootehfoot has joined #zig
_Vi has joined #zig
jokoon has joined #zig
benjif has quit [Quit: Leaving]
<Snektron> You can do that in c++ too, sadly some people on a project i had to work on decided to use that as well
<mq32> Snektron: you can do horrible things in C++
mahmudov has quit [Ping timeout: 276 seconds]
marmotini_ has joined #zig
wootehfoot has quit [Quit: Leaving]
mmx870 has joined #zig
mmx870 has quit [Ping timeout: 245 seconds]
<Snektron> ah yeah thats one of those cases of undefined behaviour which will work pretty much always but strictly you can't rely upon them
<Snektron> another fun one is pointer comparison
<Snektron> Pointer comparsion is ub unless both pointers point to the same object or members of it, or point to elements of the same array iirc
wootehfoot has joined #zig
<Snektron> Taking the address of a member of an object which is not in a valid storage location is also undefined behavior
mmx870 has joined #zig
<mq32> Snektron: yep
<mq32> it's weird at first, but is also kinda logical if you know how some architectures work and what the C compiler *may* hide
<Snektron> if you think about it, std::launder is very logical: X in the example has a const member, and thus the compiler may inline that value
<Snektron> so if you change the object X, the const value may become different
<mq32> yeah
<mq32> it's weird at first, but makes sense in some cases
<Snektron> I think C doesn't have this problem because const values aren't actually const
<Snektron> there was some post about that a while ago
<Snektron> Zig doesn't have that problem because struct fields may not be const
<mq32> yeah
<mq32> also something like "transmogrify" is horrible code :D
mmx870 has quit [Quit: The Lounge - https://thelounge.chat]
<Snektron> i think the std uses something like that
<Snektron> if you swap the allocator of one of the built in containers, it does something like `std::swap(static_cast<Allocator*>(this), static_cast<Allocator*>(other))` or something
<Snektron> Also something with empty base class compression
<mq32> yeah, cpp is weird
<mq32> has somebody here have experience with lowlevel communication in linux (mac/ieee802.11 layer)?
<mq32> i'd like to communicate out-of-band with known devices over WLAN, but cannot find much resources/documentation on that topic
marmotini_ has quit [Remote host closed the connection]
dddddd has quit [Remote host closed the connection]
marmotini_ has joined #zig
marmotini_ has quit [Remote host closed the connection]
traviss has quit [Quit: Leaving]
mmx870 has joined #zig
jokoon has quit [Quit: jokoon]
benjif has joined #zig
marmotini_ has joined #zig
marmotini_ has quit [Ping timeout: 252 seconds]
gonzus has joined #zig
<gonzus> I have a question about enums. Say I have `const Dir = enum { N, S, E, W };` -- is there an idiomatic way to iterate over the four values? I tried `for (Dir) |dir| {}` but it didn't work.
<gonzus> eijhccligjcdrnkvjkjjklbukklrbkdhnkiltgecgbhg
<gonzus> Sorry for that garbage.
<gonzus> I get `error: container 'Dir' has no member called 'len'` -- should I be looking at creating an iterator for the enum?
wootehfoot has quit [Quit: Leaving]
lunamn has joined #zig
lunamn_ has quit [Ping timeout: 265 seconds]
<lupine> Mmm, modhex
<Snektron> gonzus, try using @typeInfo: `for (@typeInfo(Dir).Enum.fields) |field| std.debug.warn("{} {}\n", .{field.name, field.value});`
gonzus has quit [Ping timeout: 260 seconds]
mahmudov has joined #zig
mahmudov has quit [Ping timeout: 245 seconds]
jokoon has joined #zig
dddddd has joined #zig
marmotini_ has joined #zig
<pixelherodev> Snektron, my point is I could do that in Zig and it's defined
data-man has joined #zig
data-man has quit [Client Quit]
data-man has joined #zig
data-man has left #zig [#zig]
data-man has joined #zig
marmotini_ has quit [Remote host closed the connection]
wootehfoot has joined #zig
marmotini_ has joined #zig
wootehfoot has quit [Read error: Connection reset by peer]
marmotini_ has quit [Remote host closed the connection]
darithorn has joined #zig
jokoon has quit [Quit: jokoon]
<data-man> gonzus, you can use std.meta.fields
<pixelherodev> Whereas in C++ it's UB that just usually works
lunamn has quit [Quit: leaving]
lunamn has joined #zig
wootehfoot has joined #zig
doublex_ has joined #zig
ur5us has joined #zig
doublex has quit [Ping timeout: 250 seconds]
mahmudov has joined #zig
<Snektron> deleting this is perfectly defined
rjtobin has joined #zig
shritesh has joined #zig
dimenus has quit [Remote host closed the connection]
<pixelherodev> Snektron, in C++?
<pixelherodev> ... what about deleting this within the constructor?
<pixelherodev> Because might be thinking of that
<Snektron> not sure about in a constructor
frmdstryr has joined #zig
<daurnimator> New zig task: write an NSS module
<pixelherodev> A wat?
<daurnimator> pixelherodev: nss. it's the magic that runs in almost every process to list users on a system/passwords/etc
<pixelherodev> Ah
<pixelherodev> Thanks
<daurnimator> --> if you can getpwnam, it looks at /etc/nsswitch.conf, dlopens the relevant modules, and asks them in turn.
<daurnimator> s/can/call/
<daurnimator> The way e.g. ldap works, is that it adds a shared object libnss-ldap.so to your system, which is loaded into every process that ever asks for user info
<daurnimator> --> zig is a great choice of language to write these modules in
<daurnimator> last night I was working on a system where we ended up using libnss-pgsql.... which has been unmaintained since 2006. Would love to rewrite it in zig.
merlyndmg has joined #zig
<pixelherodev> For structure member functions, is it better to define the first parameter (self/this/whatever you want to call it) as `T` or as `*T` if it doesn't need to modify the original?
<pixelherodev> That is to say, is there a performance benefit to passing as a pointer?
<daurnimator> pixelherodev: always prefer T if you can
<daurnimator> pixelherodev: if you write T, zig gets to choose between T and *T and picks whatever is faster. if you write *T zig has no choice
<pixelherodev> Gotcha
<pixelherodev> Thanks!
<pixelherodev> Then it's just a matter of whether I actually need *T here...
shritesh has quit [Quit: shritesh]
<pixelherodev> I'm modifying an object pointed to by a field in T (e.g. self.a is an array list of which an item *in* the list is being modified)
<pixelherodev> So I think T is fine
<pixelherodev> Since the array list itself isn't being modified, and thus T itself *should* be unaffected by all of these changes
<pixelherodev> So yeah, thanks
shritesh has joined #zig
wootehfoot has quit [Read error: Connection reset by peer]
ur5us has quit [Ping timeout: 250 seconds]
ur5us has joined #zig
_whitelogger has joined #zig
<merlyndmg> Is it possible to do a comptime assert when passing a `union(enum)` value to ensure that it is a subset of values?E.g. `std.debug.assert(op == .BoolAnd or op == .BoolOr);`
<merlyndmg> The above is not erroring for me at compile time