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/
<zags> not gonna lie, i miss smart pointers :) i think someone had been pondering about that for zig, but not sure how well that could work without destructors to release at end of scope/lifetime
montezuma has joined #zig
plumm has quit [Ping timeout: 240 seconds]
plumm has joined #zig
zags has quit [Ping timeout: 246 seconds]
geemili has joined #zig
n0tekky has quit [Read error: Connection reset by peer]
montezuma has quit [Quit: WeeChat 2.8]
plumm has quit [Ping timeout: 264 seconds]
plumm has joined #zig
kbd has joined #zig
<kbd> Dumb question: How do I compare a null-terminated string? `std.mem.eql(u8, os.argv[1], "...")` doesn't work, what's the right type over u8?
cole-h has joined #zig
<daurnimator> kbd: usually get a null terminated slice first. see std.mem.spanZ
<kbd> that works, thanks. I don't understand why though. Most of my "wasted" time learning Zig is just trying to get the types of slices/arrays/strings right.
<daurnimator> in C when you get it wrong it silently works except you have a security hole. zig *makes* you think about it
braket has joined #zig
<daurnimator> kbd: you may also use `std.cstr.eql` instead of `std.mem.eql`
<daurnimator> uh,. std.cstr.cmp
<kbd> thanks again daurnimator
gazler has joined #zig
gazler_ has quit [Ping timeout: 240 seconds]
<kbd> thanks again daurnimator
<kbd> whoops alt tab + up arrow enter went to the wrong window 🤦‍♂️
kbd has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
plumm has quit [Quit: My Mac Pro has gone to sleep. ZZZzzz…]
<braket> Is there a name for the data types that can be constructed with `T{}`? Trying to update some docs but I'm blanking on what to call them.
<g-w1> struct
<g-w1> b
<g-w1> sorry
kbd has joined #zig
kbd has quit [Client Quit]
craigo has joined #zig
earnestly has quit [Ping timeout: 265 seconds]
kbd has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
<kbd> What's the stance on high level command line argument parsing in the stdlib? Just needs to be written, or out of scope?
<g-w1> zig-clap is out there, although there seems to be a sentiment that you should roll your own out of simplicity
yeti has quit [Quit: WeeChat 3.0]
yeti has joined #zig
yeti has quit [Read error: Connection reset by peer]
yeti has joined #zig
kbd has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
<braket> g-w1 arrays, enums, and unions also use T{} though
<tdeo> i don't think enums do
<braket> ah, you're right, not enums
plumm has joined #zig
kbd has joined #zig
plumm has quit [Quit: My Mac Pro has gone to sleep. ZZZzzz…]
kbd has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
v0idify has quit [Ping timeout: 268 seconds]
v0idify has joined #zig
leon-p has quit [Quit: leaving]
Biolunar has joined #zig
ncon has quit [Remote host closed the connection]
ncon has joined #zig
jokoon has joined #zig
sord937 has joined #zig
braket has quit [Ping timeout: 265 seconds]
gazler_ has joined #zig
gazler has quit [Ping timeout: 240 seconds]
xackus has joined #zig
zags has joined #zig
teratorn has quit [Quit: quit]
teratorn has joined #zig
ky0ko has quit [Read error: Connection reset by peer]
ky0ko has joined #zig
<zags> is there a way to build types in a staggered fashion at compile time? For instance, call various functions that add fields to a struct to produce the final type.
<ikskuh> heya o/
<ikskuh> zags: you can build yourself a struct builder :)
<ikskuh> shouldn't be that much of work actually
<ikskuh> nice thing with comptime is that you can just append stuff to slices with ++
<ikskuh> struct { fields: []std.meta.TypeInfo.StructField, fn append(self: *@This(), std.meta.TypeInfo.StructField) { … } fn finalize(self: @This()) type { … } }
<zags> what's the ingredients of a struct builder? Note that this is exposed to the user side, so x.a().b().doit(), so only after b() is the type known
<zags> (x is a type, not a runtime variable)
<zags> aha, std.meta have the ingredients, interesting
<zags> type { … }, how does the actual finalization step work?
<ikskuh> @Type()
<ikskuh> std.builtin, sorry
<ikskuh> not std.meta
<ikskuh> note that a builder interface isn't typical zig style
<zags> I'm disregarding that in this case
<zags> I have a functional-style streams api going, and those typically have fluid api style, which I like so that's what'll be :)
<zags> Building the stream pipeline at compiletime will make it completely free of heap allocations, so I wanna look into that.
<ikskuh> have fun
<zags> ikskuh: that's pretty darn nice, thanks!
<ikskuh> also straightforward ;)
<zags> Zig is awesome
<ikskuh> yes.
jsb has quit [Quit: .]
earnestly has joined #zig
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
jsb has joined #zig
cole-h has quit [Ping timeout: 272 seconds]
dreda has quit [Ping timeout: 265 seconds]
<ikskuh> self-promotion: https://zig.pm/#/package/args
<ikskuh> alternative
<tane> ok nice, thank you
<tane> one other Q: how to initialize a null-slice? something where .ptr may be garbage, but at least .len = 0
<tane> I can always make it =undefined, then set .len afterwards. is there a better way?
<ikskuh> const slice: []const u8 = &[_]u8{};
<tane> thanks
<tane> I've invested a bit more time getting into zig, and it's quite fun! :)
<ikskuh> cool!
craigo has quit [Quit: Leaving]
sord937 has quit [Ping timeout: 268 seconds]
sord937 has joined #zig
geemili has quit [Ping timeout: 264 seconds]
jokoon has quit [Quit: Leaving]
leon-p has joined #zig
xackus has quit [Ping timeout: 264 seconds]
xackus has joined #zig
decentpenguin has quit [Ping timeout: 265 seconds]
decentpenguin has joined #zig
plumm has joined #zig
donniewest1 has joined #zig
plumm has quit [Quit: My Mac Pro has gone to sleep. ZZZzzz…]
plumm has joined #zig
braket has joined #zig
x1212 has joined #zig
plumm has quit [Quit: My Mac Pro has gone to sleep. ZZZzzz…]
plumm has joined #zig
maier has joined #zig
plumm has quit [Quit: My Mac Pro has gone to sleep. ZZZzzz…]
Akuli has joined #zig
<g-w1> ikskuh, is there a way to use with with a defer, like deniting a withed variable?
plumm has joined #zig
braket has quit [Ping timeout: 240 seconds]
plumm has quit [Quit: My Mac Pro has gone to sleep. ZZZzzz…]
sawzall has quit [Read error: Connection reset by peer]
sawzall has joined #zig
plumm has joined #zig
sawzall has quit [Read error: Connection reset by peer]
kbd has joined #zig
sawzall has joined #zig
kbd has quit [Client Quit]
<ikskuh> g-w1: no, it's intentionally not included to keep it simple.
plumm has quit [Quit: My Mac Pro has gone to sleep. ZZZzzz…]
plumm has joined #zig
plumm has quit [Quit: Textual IRC Client: www.textualapp.com]
zags has quit [Ping timeout: 264 seconds]
<g-w1> ok
bitmapper has quit [Quit: Connection closed for inactivity]
ky0ko has quit [Ping timeout: 246 seconds]
maier has quit [Quit: Lost terminal]
Akuli has quit [Quit: Leaving]
Akuli has joined #zig
daurnimator has quit [Ping timeout: 272 seconds]
waleee-cl has joined #zig
zags has joined #zig
dch has quit [Read error: Connection reset by peer]
dch has joined #zig
xackus has quit [Ping timeout: 256 seconds]
daurnimator has joined #zig
bitmapper has joined #zig
xackus has joined #zig
hnOsmium0001 has joined #zig
a_chou has joined #zig
sawzall has quit [Read error: Connection reset by peer]
sawzall has joined #zig
sawzall has quit [Read error: Connection reset by peer]
sawzall has joined #zig
braket has joined #zig
x1212 has quit [Quit: Leaving]
braket has quit [Ping timeout: 240 seconds]
nycex has joined #zig
nycex- has quit [Remote host closed the connection]
geemili has joined #zig
<tane> hm, var rng = std.rand.Pcg.init(42).random;
<tane> that works, but reads some stack-garbage due to @fieldParentPtr and there seems no easy way to actually detect this misuse
<ifreund> tane: yeah, this is known design flaw, though there is an accept open propsal to fix it
<ifreund> it just hasn't been implemented yet
<tane> ifreund, thanks for the pointer
mwgkgk has joined #zig
sawzall has quit [Read error: Connection reset by peer]
sawzall has joined #zig
wootehfoot has joined #zig
leah2 has quit [Ping timeout: 264 seconds]
leah2 has joined #zig
marijnfs has joined #zig
<marijnfs> whats up in zig land?
<ikskuh> hey marijnfs o/
<ifreund> o7
<marijnfs> no recent showtime?
<marijnfs> do functions types yet
<marijnfs> whatsup
<marijnfs> o\
<g-w1> showtime is tmrw
<marijnfs> sweet
<marijnfs> topics?
<g-w1> Year of the Linux Gaming Desktop
Xavi92 has joined #zig
Xavi92 has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
cole-h has joined #zig
<andrewrk> marler8997, I want to make sure to give you the spotlight you deserve in this talk ^ :)
<andrewrk> tbh I haven't started on the talk yet tho, I better get on that
Akuli has quit [Quit: Leaving]
<marler8997> spotlight huh?
wootehfoot has quit [Read error: Connection reset by peer]
<andrewrk> yeah remember when we were going back and forth on the linux binary to make the vulkan triangle?
<andrewrk> that's what the talk is about
<marler8997> oh cool, I guess I'm gonna be famous now, I'll be sure to get an agent and I'll try not to forget my now peon friends
sord937 has quit [Quit: sord937]
a_chou has quit [Quit: a_chou]
<andrewrk> lol I think this is gonna get 4K views, tops
xackus has quit [Ping timeout: 265 seconds]
mwgkgk has quit [Quit: Connection closed for inactivity]
donniewest1 has quit [Quit: WeeChat 3.0.1]
xackus has joined #zig
<zags> pub fn something(slice: anytype) std.meta.Child(@TypeOf(slice))
zags has quit [Quit: Lost terminal]
zags has joined #zig
<zags> is that supposed to work?
<ikskuh> yep
<ikskuh> looks fine
<zags> ok, must be just a bad compiler error then, it claims I'm returning "slice"
<zags> probably have some error elsewhere
<ikskuh> code snippet?
<zags> nah, it's a big mess, i'll try to sort it knowing it's supposed to work, will make a testcase if I can't :D
<ikskuh> are you maybe passing in a string?
<ikskuh> something("foo")
<zags> oof, was returning the wrong thing, was just a confusing error message.
<zags> out of curiosity, is it safe, like in c++, to self destruct? Basically alloc.free(self). Any by safe, I mean under the assumption the struct was allocated with the same allocator haha.
<ikskuh> sure
<ikskuh> there is no *this* ;)
<ikskuh> no concept of "self"
<ikskuh> there is only functions, arguments and values :)
<zags> yeah, no hidden machinery at all, should be safe then
<ikskuh> "self-destruct" is actually pretty common over all stdlib
<zags> I see, good to know
posixlix has joined #zig
<posixlix> Hey everyone! Is there a well-defined way of accessing a tagged union's tag and payload? (Basically this issue, https://github.com/ziglang/zig/issues/3641, but I really would prefer to not incur the runtime cost of the other options, even if it's just a few cmp instructions.)
<posixlix> I made a hack that allows me to do the aforementioned, but it would very quickly become invalidated with any change to tagged unions' layout and probably doesn't account for some edge cases anyway.
<posixlix> (To clarify, I want to initialize a tagged union with a runtime-known tag value)
<posixlix> e.g this: `var val: Foo_Union = undefined; val.tag (this doesn't work) = my_tag_value_that_i_got_from_somewhere;`