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/
gpanders has joined #zig
gpanders has quit [Remote host closed the connection]
gpanders has joined #zig
a_chou has quit [Ping timeout: 258 seconds]
ky0ko_ has joined #zig
lqd has quit [Quit: Connection closed for inactivity]
<kandinski> One question about this snippet: https://termbin.com/tpx0
<kandinski> if tryToAllocateFoo() fails with an error, `foo` (of type !Foo) is now an error, which will be returned.
a_chou has joined #zig
<kandinski> `errdefer deallocateFoo(foo);` will trigger and deallocate what?
<kandinski> I understand errdefer behaviour if the error returnned is OutOfMemory or InvalidParam
<kandinski> but what's errdefer behaviour if the error returned is error.TryToAllocateError?
xackus has quit [Ping timeout: 260 seconds]
<kandinski> aaah, it returns from the expression with the same error, so errdefer is never reached
<kandinski> (-!- kandinski renamed channel #zig to #rubberducky)
<mattnite> errdefer is triggered when the block exits with _any_ error
<kandinski> mattnite, but in the snippet it won't trigger if the error is in the tryToAllocateFoo() call
<kandinski> because `const try tryToAllocateFoo();` returns before errdefer sets up the cleanup hook.
<kandinski> (I think: I just asked a question and answered it myself; but the call to `deallocateFoo(foo)` makes no sense if foo wasn't allocated)
<kandinski> a reminder of what the snippet was: https://termbin.com/tpx0
<mattnite> Sorry wasn't exact, you're correct, you have to hit the errdefer for it to be "registered"
<kandinski> sure, thanks
<kandinski> my mental model was incorrect
<mattnite> I skimmed the code a little to fast :P
<mattnite> too*
<kandinski> (somehow in my mental model `foo = try blargh()` meant the variable now contained the error, instead of the block exiting with the error)
<mattnite> ah, yeah you'd have the error if there was no try
<kandinski> I don't really know C, I'm learning zig as an exciting opportunity to catch up on system programming without having to take on historical baggage of mentally learning about all the quirks and warts
st4ll1 has joined #zig
a_chou has quit [Quit: a_chou]
earnestly has quit [Ping timeout: 272 seconds]
dermetfan has quit [Ping timeout: 272 seconds]
nephele_ has joined #zig
nephele has quit [Ping timeout: 240 seconds]
nephele_ is now known as nephele
mattnite has quit [Remote host closed the connection]
waleee-cl has quit [Quit: Connection closed for inactivity]
cole-h has quit [Quit: Goodbye]
cole-h has joined #zig
a_chou has joined #zig
a_chou has quit [Quit: a_chou]
GrooveStomp has joined #zig
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
joey152 has quit [Remote host closed the connection]
marnix has quit [Ping timeout: 260 seconds]
marnix has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
cole-h has quit [Quit: Goodbye]
decentpenguin has quit [Read error: Connection reset by peer]
marnix has joined #zig
decentpenguin has joined #zig
marnix has quit [Read error: Connection reset by peer]
lqd has joined #zig
khr has joined #zig
<khr> hello folks. first foray into zig here, anyone have a simple example of a build.zig file which adds a C header include directory? the docs are a bit sparse on the subject of build.zig and std.build at the moment.
<ikskuh> heya
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
<ikskuh> Wohnungsgeberbestätigung
<ikskuh> dang :D
<ikskuh> this should get you started
<khr> ah brilliant, this is useful, thanks
<ikskuh> you're welcome
<ikskuh> i just noticed that this build.zig is a damn good example for a lot of features
<ikskuh> (i've stripped out dependencies/pregeneration of other files)
earnestly has joined #zig
<daurnimator> ikskuh: interesting pattern with the `const pkgs = struct {`
<ikskuh> yeah i noticed that it's way more readable as soon as you have more than one project requiring packages
<ikskuh> here's a public gist. share it! :D
shtanton has joined #zig
khr has quit [Ping timeout: 260 seconds]
ur5us has joined #zig
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
traviss has quit [Remote host closed the connection]
traviss has joined #zig
shtanton has quit [Quit: Quit]
shtanton has joined #zig
shtanton has quit [Read error: Connection reset by peer]
shtanton has joined #zig
drvirgilio has quit [Ping timeout: 244 seconds]
drvirgilio has joined #zig
dermetfan has joined #zig
ur5us has quit [Ping timeout: 240 seconds]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
ask6155 has joined #zig
<ask6155> hello
<ask6155> There is a c function which returns a char32_t how do I initialize it in zig?
<ikskuh> it's u32
<ask6155> How do I know what types c types correspond to?
<daurnimator> char32_t isn't standard C type. so you need to look at the library you're using
<ikskuh> daurnimator: please update your internal c reference: https://en.cppreference.com/w/c/string/multibyte/char32_t
<daurnimator> ikskuh: looks like C++ to me
<ikskuh> it's c though ;)
<daurnimator> also looks like they not only named it badly; but got it wrong too
<daurnimator> ikskuh: nope
<ikskuh> it is!
<ikskuh> it's in /c/, not /cpp/, also it tells me "C11" and "C99", not "c++11" and "c++98" ;)
<daurnimator> ikskuh: seems to be C++11 only ?
<ikskuh> C11
<ikskuh> even though C++11 also has this
<daurnimator> ah crap
<daurnimator> well congrats C standards people..... you got another definition wrong >.<
<ask6155> u32 does work
<daurnimator> to represent utf-32 you need at most u21... but they've defined it as "at least u32"
<ask6155> but chare32_t is not given in the documentation
<ask6155> in zig documentation that is
shtanton has quit [Read error: Connection reset by peer]
shtanton has joined #zig
marnix has joined #zig
shtanton has quit [Read error: Connection reset by peer]
shtanton has joined #zig
shtanton has quit [Read error: Connection reset by peer]
shtanton has joined #zig
shtanton has quit [Read error: Connection reset by peer]
shtanton has joined #zig
marnix has quit [Read error: Connection reset by peer]
shtanton has quit [Client Quit]
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
mokafolio has quit [Client Quit]
ask6155 has left #zig ["Later!"]
lanodan has quit [Read error: Connection reset by peer]
mokafolio has joined #zig
lanodan has joined #zig
lanodan has quit [Read error: Connection reset by peer]
lanodan has joined #zig
dermetfan has quit [Quit: WeeChat 2.7.1]
mokafolio has quit [Quit: Bye Bye!]
waleee-cl has joined #zig
mokafolio has joined #zig
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
layneson has joined #zig
mschwaig has joined #zig
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
LanceThePants has quit [Read error: Connection reset by peer]
marnix has joined #zig
LanceThePants has joined #zig
marnix has quit [Read error: Connection reset by peer]
mschwaig has quit [Quit: WeeChat 2.8]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
layneson has quit [Ping timeout: 256 seconds]
marnix has joined #zig
Akuli has joined #zig
evgeniuz has joined #zig
evgeniuz has quit [Client Quit]
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
marnix has quit [Ping timeout: 240 seconds]
marnix has joined #zig
layneson has joined #zig
cole-h has joined #zig
Barabas has joined #zig
<Barabas> Heya
<Barabas> How do I convert a pointer to a single element to a slice?
<leeward> I think you'd have to put it in an array first.
<leeward> Or do you have a pointer to a single element of an array?
<Barabas> No, I just have a pointer to a single object
<Barabas> And my function expects a slice. I thought it'd automatically convert, but it doesn't and a @ptrCast also didn't work on a slice
<ikskuh> you can just convert the pointer and slice it:
<ikskuh> @ptrCast([*]T, &obj)[0..1]
<fengb> `&[_]T{foo}` or `@as([*]T, &foo)[0..1]`
<Barabas> Yeah, ok. The ptrCast is quite ugly though
<ikskuh> the first one isn't really a good variant
<ikskuh> @Barabas, there is a function for that in std.mem i think
<ikskuh> fengb: because you don't point to the original value but a copy
<ikskuh> it works for readonly data, yes
<Barabas> ikskuh I can't find the function. `span` looks like it, but that doesn't accept a single pointer it seems.
<ikskuh> hm
<ikskuh> maybe i should add it or the coercion of single item pointer to multi-item-pointer is accepted some day…
joey152 has joined #zig
xackus has joined #zig
a_chou has joined #zig
LanceThePants has quit [Read error: Connection reset by peer]
LanceThePants has joined #zig
wootehfoot has joined #zig
lqd is now known as phazon
phazon is now known as lqd
GrooveStomp_ has joined #zig
xackus has quit [Read error: Connection reset by peer]
swills has quit [Ping timeout: 240 seconds]
xackus_ has joined #zig
marnix has quit [Ping timeout: 264 seconds]
<leeward> fn toArray(comptime T: type, *T) [1]T
<leeward> mmm, that'd be a *[1]T
swills has joined #zig
joey152 has quit [Quit: Leaving]
marnix has joined #zig
layneson has quit [Ping timeout: 260 seconds]
waleee-cl has quit [Quit: Connection closed for inactivity]
mokafolio has quit [Quit: Bye Bye!]
swills has quit [Ping timeout: 265 seconds]
mokafolio has joined #zig
swills has joined #zig
a_chou has quit [Ping timeout: 246 seconds]
layneson has joined #zig
waleee-cl has joined #zig
LanceThePants has quit [Read error: Connection reset by peer]
LanceThePants has joined #zig
wootehfoot has quit [Read error: Connection reset by peer]
wootehfoot has joined #zig
_Vi has joined #zig
Barabas has quit [Remote host closed the connection]
wootehfoot has quit [Read error: Connection reset by peer]
a_chou has joined #zig
marnix has quit [Ping timeout: 272 seconds]
SimonNa has quit [Remote host closed the connection]
frmdstryr has joined #zig
SimonNa has joined #zig
a_chou has quit [Quit: a_chou]
layneson has quit [Ping timeout: 260 seconds]
ur5us has joined #zig
frmdstryr has quit [Ping timeout: 258 seconds]
ur5us_ has joined #zig
arqv has joined #zig
ur5us has quit [Ping timeout: 258 seconds]
xackus_ has quit [Remote host closed the connection]
xackus_ has joined #zig
<dmiller> Does anyone have a little snippet handy showing how to create an AutoHashMap with strings as keys? As a systems programming newbie I'm having a hard time figuring out how to do it since strings seem to usually be represented as `[]u8` which is a pointer at the end of the day. Pointers aren't very useful as keys, it turns out!
<andrewrk> dmiller, std.StringHashMap
<andrewrk> you can see some usage examples in tools/*.zig
Akuli has quit [Quit: Leaving]
xackus_ has quit [Ping timeout: 240 seconds]
xackus_ has joined #zig
a_chou has joined #zig
ur5us_ has quit [Read error: Connection reset by peer]
ur5us_ has joined #zig
_Vi has quit [Ping timeout: 272 seconds]
a_chou has quit [Ping timeout: 272 seconds]
xackus_ has quit [Ping timeout: 240 seconds]
<johnLate> I want to read from a json file. I'm trying to simplify var value1 = tree.root.Object.get("a").?.value.Object.get("x").?.value.Object.get("1").?.value;
<johnLate> into something like: var value3 = J.lookup(tree.root, .{ "a", "x", "1"});
<johnLate> So far, I've achieved: value2 = J.lookup(tree.root, &[_][]const u8{ "a", "x", "1" });
<johnLate> I'm wondering if this is the right way to do it or what I could do better: https://gist.github.com/johnLate/0bde3cf2cc2440889d2bdffa117ec2d6