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/
sebonirc has quit [Ping timeout: 276 seconds]
kbd has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
kbd has joined #zig
<ifreund> andrewrk: not going to get pointer types done tonight. I'm off to bed now, will rebase and pick it up again in the morning
<andrewrk> good night! thanks for the help today
<ifreund> you're welcome :)
nvmd has quit [Read error: Connection reset by peer]
nvmd has joined #zig
zags has joined #zig
kbd has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
<zags> i'm passing structs to a function taking "anytype". Is there a way to access/update this struct by field index rather than name?
kbd has joined #zig
<zags> or iterate over field members and set them, if possible
<andrewrk> you can use @typeInfo for that and there are some helper methods in std.meta
<zags> noice, thanks
<zags> is there a more terse way to express arrays of string literals than
<zags> []const []const u8 = &.{"aaaa", "bbbbb"}
<zags> ?
<zags> I got that from #7200 because I couldn't find another way haha
kbd has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
<zags> anyway, std.meta and @field made it easy to write a generic zip :D https://pastebin.com/raw/qsPJ4t8U
* zags zigs to zip
leon-p has quit [Quit: leaving]
kevasmith has quit [Ping timeout: 264 seconds]
gazler__ has joined #zig
gazler_ has quit [Read error: Connection reset by peer]
zags has quit [Quit: leaving]
jukan has quit [Ping timeout: 276 seconds]
kbd has joined #zig
kbd has quit [Client Quit]
kbd has joined #zig
kevasmith has joined #zig
sebonirc has joined #zig
dyeplexer has joined #zig
sebonirc has quit [Ping timeout: 240 seconds]
kbd has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
kbd has joined #zig
<andrewrk> ifreund, I'm done working for today but I started on asm expressions
kbd has quit [Quit: Textual IRC Client: www.textualapp.com]
earnestly has quit [Ping timeout: 240 seconds]
v0idify has quit [Remote host closed the connection]
v0idify has joined #zig
ex_nihilo has quit [Quit: Leaving]
cole-h has joined #zig
kevasmith has quit [Ping timeout: 276 seconds]
mikdusan1 has joined #zig
decentpenguin has quit [Ping timeout: 276 seconds]
washbear has quit [Ping timeout: 276 seconds]
decentpe- has joined #zig
ifreund has quit [Ping timeout: 276 seconds]
decentpe- is now known as decentpenguin
mikdusan has quit [Ping timeout: 276 seconds]
ifreund has joined #zig
racoon has joined #zig
_whitelogger has joined #zig
bitmapper has quit [Quit: Connection closed for inactivity]
waleee-cl has quit [Quit: Connection closed for inactivity]
Xatenev has joined #zig
gpanders has quit [Quit: ZNC - https://znc.in]
gpanders has joined #zig
cole-h has quit [Ping timeout: 240 seconds]
Xatenev has left #zig [#zig]
frett27 has joined #zig
osa1 has quit [Quit: osa1]
osa1 has joined #zig
earnestly has joined #zig
xackus_ has joined #zig
craigo has quit [Ping timeout: 272 seconds]
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
Swahili has joined #zig
<Swahili> Hi :)
<ifreund> o7
leon-p has joined #zig
Swahili has quit [Remote host closed the connection]
gazler has joined #zig
gazler__ has quit [Ping timeout: 246 seconds]
frett27 has quit [Ping timeout: 272 seconds]
geemili has joined #zig
ifreund has quit [Ping timeout: 276 seconds]
ifreund has joined #zig
frett27 has joined #zig
gazler_ has joined #zig
leon-p has quit [Ping timeout: 276 seconds]
g-w1 has quit [Ping timeout: 276 seconds]
leon-p has joined #zig
g-w1 has joined #zig
gazler has quit [Ping timeout: 276 seconds]
di-wu has joined #zig
GrooveSt- has quit [Quit: ZNC 1.7.2+deb3 - https://znc.in]
Biolunar has quit [Ping timeout: 264 seconds]
GrooveStomp has joined #zig
Biolunar has joined #zig
zags has joined #zig
<zags> ifreund: great fosdem talk, very effective pedagogy
<ifreund> thank you!
<ifreund> if you have any questions you can join #fosdem-zig on freenode to ask them
<ikskuh> or you can send me the message and i will forward it
bitmapper has joined #zig
cole-h has joined #zig
<zags> hmm, no way to chain together functions that may fail? I was somehow expecting try f().!.g() to work
<ikskuh> zags: nope, just call them one after another
<zags> that didn't compile, says:
<zags> type '@typeInfo(@typeInfo(@TypeOf(MyType(u8).from)).Fn.return_type.?).ErrorUnion.error_set!*MyType(u8)' does not support field access
<ifreund> try g(try f())
<zags> yikes
<ifreund> or maybe try (try f()).g();
<zags> f isn't an argument though
<zags> oh the lsat one
<ifreund> not sure what exactly you intended
<zags> i intent to have a generic struct returning !*@This() so I can chain calls together
<ifreund> note that try foo() is just sugar for foo() catch |err| return err
<zags> this is a stream-style API, I need the chaining syntax to be smooth
<zags> can easily be 10-15 calls
<zags> i wonder if there's an issue proposal to fix this or if I should write something
<ifreund> Don't know of one off the top of my head
<zags> it's like Java streams, so from(slice).filter(less).map(something).foreach(...something...)
<ifreund> yeah I see what your goal
<zags> cool
<ifreund> I'm trying to think of a better way to do that
<zags> so the current parenthesised try chaining makes it a no-go in terms of api usability
<zags> ifreund: one way is to not propagate errors in functions, but keep a stream state
<zags> then ignore chained calls if there's an error
<zags> then propagate error in the terminating call
<zags> i think i'll do that
<zags> not optimal, but ok
<ifreund> yeah that makes sense
<ifreund> I'm not sure that's inherently suboptimal either, it would certainly be less branchy
<zags> and an error flag isn't exactly much memory overhead either
frett27 has quit [Ping timeout: 265 seconds]
<zags> ifreund: embarrasing noob question... but an error flag can simply be "var err: anyerror!void = undefined;" right ? And then I do "if (err) {} else |e| { return e; }" in the terminating functions of the stream. Maybe there's a better way.
<zags> i guess "err" should actually be called "ok" here :D
<ifreund> zags: just anyerror should work I think
<ifreund> o
<ifreund> oh though you want to store the case where there was no error as well, yeah that works
waleee-cl has joined #zig
<zags> expected error union type, found 'anyerror
<zags> alright, thanks
craigo has joined #zig
<zags> Yay, it works
<zags> var result = try intStream.from(&ages).filter(lessThan(500)).map(f64, asFloat64).reduce(@as(f64,1), mul);
<zags> std.testing.expectEqual(result, 39270);
<zags> zig <3
<ifreund> very cool, I haven't seen anyone make an API like that in zig yet :)
<zags> might make a lib out of it
<zags> could lazyness and parallelism
<zags> could add*
Swahili has joined #zig
wootehfoot has joined #zig
cole-h has quit [Ping timeout: 256 seconds]
frett27 has joined #zig
Akuli has joined #zig
gpanders_ has joined #zig
gpanders has quit [Ping timeout: 276 seconds]
earnestly has quit [Ping timeout: 276 seconds]
earnestly has joined #zig
a_chou has joined #zig
<viashimo> when - if ever - would @TypeOf return .Struct?
<viashimo> I'm trying to use an AutoHashMap where the key is a struct (I think... eg. const S = struct { ... }), but since @TypeOf returns .Type, the default hash function won't work with it
<g-w1> do const S = struct { ... }; const item_of_type_s = S{ ... }; then you can hash item_of_type_s
a_chou has quit [Remote host closed the connection]
dyeplexer has quit [Remote host closed the connection]
<viashimo> g-w1: thanks for the suggestion. it doesn't seem to work though. I get the following error: error: expected type 'type', found 'S' when declaring `var hm: std.hash_map.AutoHashMap(item_of_S, u64)`
<g-w1> hmm, oh yeah S should work ...
txdv has joined #zig
<txdv> Hi guys, are there videos of the second 2 talks of FOSDEM available somewhere to watch?
<ikskuh> no public FOSDEM talk available yet
<ikskuh> https://mq32.de/public/fosdem2021.mp4 this is my talk, but no Q&A
<txdv> nice
<txdv> did you use latex for your slides?
<ikskuh> yeah
<ikskuh> beamer, default
knebulae has quit [Remote host closed the connection]
knebulae has joined #zig
wootehfoot has quit [Ping timeout: 265 seconds]
a_chou has joined #zig
hnOsmium0001 has joined #zig
midgard has quit [Read error: Connection reset by peer]
midgard has joined #zig
txdv has quit [Ping timeout: 256 seconds]
a_chou has quit [Remote host closed the connection]
<Swahili> Is the version from "brew install zig", the master version mentioned in https://github.com/zigtools/zls/issues/222?
<ifreund> Swahili: that depends, what version does homebrew give you? You can run `zig version` to find out
<Swahili> ifreund: thanks for looking! I have 0.7.1 just getting started with zig from today
<Swahili> thought about just writing "tests" to learn a bit
<ifreund> Swahili: that would not be the master version then, master would say something like 0.8.0-dev.1071+7069459a7
<Swahili> but thought about adding the zig language server
<Swahili> ifreund: ok thanks, I'll try brew install zig --HEAD
<ifreund> if you haven't seen this webside yet, I'd highly recommend checking it out: https://ziglearn.org/
<Swahili> ifreund: yeh checking it, but also checking the main docs
<ifreund> the main docs are good if you're already comfortable with low-level programming and just need a language reference to get going
<Swahili> ifreund: ok thanks for letting me know ;)
Swahili has quit [Remote host closed the connection]
frett27 has quit [Ping timeout: 246 seconds]
Swahili has joined #zig
<ifreund> andrewrk: I've been distracted/occupied by fosdem today, getting back to pointer types now though (there sure are a lot of pointer types :D)
ur5us has joined #zig
lohengrin has quit [Ping timeout: 272 seconds]
lohengrin has joined #zig
kevasmith has joined #zig
v0idify has quit [Remote host closed the connection]
v0idify has joined #zig
zags has quit [Quit: leaving]
<Swahili> I'm testing zig with vscode and the zls. The auto-completion is not fully available right?
<ifreund> I get pretty good autocompletion in kakoune with zls
<Swahili> Let's say, I do @import("std").*, I'd like to see what's available, does that work?
<Swahili> kakoune, I'll check that
<ifreund> interesting, trying to autocomplete right after the @import("std") doesn't work. doing const std = @import("std"); std.<try to complete> does though
<Swahili> ifreund: I'll check that on vscode :) I also just found https://ziglang.org/documentation/master/std/
<Swahili> this will do, to get started :)
<ifreund> note that the autogenerated std docs there are not complete, there is stuff in the source that isn't listed there
<ifreund> I personally just read the std source
<ifreund> (which goto-definition from zls helps a lot with)
<ifreund> andrewrk: it feels weird that the c of [*c] is treated as an identifier by the tokenizer...
<ifreund> I feel like there probably isn't anything that could be done about that though
ur5us has quit [Quit: Leaving]
ur5us has joined #zig
ur5us has quit [Ping timeout: 240 seconds]
veltas has left #zig [#zig]
kevasmith has quit [Ping timeout: 240 seconds]
hamoko[m] has joined #zig
zag has joined #zig
<zag> What would the idiomatic zig way be in terms of heterogenous containers?
nvmd has quit [Quit: Later nerds.]
<justin_smith> zag: if I understand your question correctly, I think it's making a tagged union type for the types the container allows
<justin_smith> the compiler ensures that code consuming tagged unions has cases to handle the tagged types
<v0idify> is there a way to tell the event loop or a specific frame to run on the main thread?
<zag> justin_smith: looks like a good approach, thanks
<zag> justin_smith: but wait, that means every item is as large as the largest type right?
<justin_smith> right, but if that's a concern it's easy to use a pointer to limit the max to usize
<justin_smith> zag: I don't know how a heterogenous collection would work otherwise (in languages where it's trivial, everything is a pointer)
<justin_smith> (every non-primitive / non-array that is)
ky0ko has joined #zig
<ifreund> you can store a tagged union of pointers if you want
cole-h has joined #zig
<justin_smith> right, that's what I meant
<ifreund> though then you need to allocate memory separately for each element
<zag> sure, like, java makes it easy by having a common root type for everything
<zag> separate allocation is fine
<justin_smith> zag: not just that - it only supports heap allocation, and only allows passing args as pointers
<zag> args are values actually
<zag> but some values are references :)
<zag> primitives and references are values
<zag> passed by copy
<zag> *value
<zag> i'll do the tagged union of pointers thing
nycex- has joined #zig
Akuli has quit [Quit: Leaving]
nycex has quit [Ping timeout: 268 seconds]
<ifreund> andrewrk: pointer types done and PR up :) I'm off to bed now
mikdusan1 has quit [Quit: WeeChat 2.5]
wootehfoot has joined #zig
wootehfoot has quit [Ping timeout: 265 seconds]