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?
<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