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/
squeek502 has joined #zig
wootehfoot has quit [Quit: Leaving]
data-man has joined #zig
<data-man> Hello everyone! Just updated Zig syntax for dte editor. Happy coding! :) https://github.com/craigbarnes/dte/pull/152
data-man has quit [Quit: Konversation terminated!]
craigo has quit [Ping timeout: 246 seconds]
<ugla> Oh, I have one of those too, but for editors that use GtkSourceView https://git.sr.ht/~alva/zig-language-spec
nvmd has quit [Quit: Later nerds.]
data-man has joined #zig
<data-man> Announcement: Unicode matchers for Mecha (a parser combinator library). Stay tuned! :-) https://github.com/Hejsil/mecha/pull/17
data-man has quit [Quit: Konversation terminated!]
jicksaw has quit [Quit: ZNC is kill]
jicksaw has joined #zig
ifreund has quit [Remote host closed the connection]
ifreund has joined #zig
leon-p has quit [Ping timeout: 264 seconds]
mmohammadi9812 has quit [Ping timeout: 264 seconds]
mmohammadi9812 has joined #zig
leon-p has joined #zig
gazler has joined #zig
gazler_ has quit [Ping timeout: 240 seconds]
leon-p has quit [Ping timeout: 265 seconds]
haberman has joined #zig
mmohammadi9812 has quit [Ping timeout: 240 seconds]
mmohammadi9812 has joined #zig
haberman has quit [Quit: Ping timeout (120 seconds)]
earnestly has quit [Ping timeout: 246 seconds]
_whitelogger has joined #zig
semarie has quit [Quit: WeeChat 3.0]
cole-h has joined #zig
semarie has joined #zig
proteusguy has quit [Remote host closed the connection]
proteusguy has joined #zig
a_chou has joined #zig
redj_ has quit [Ping timeout: 260 seconds]
a_chou has quit [Remote host closed the connection]
craigo has joined #zig
jukan_ has quit [Ping timeout: 246 seconds]
jukan has joined #zig
cole-h has quit [Ping timeout: 240 seconds]
mmohammadi9812 has quit [Ping timeout: 264 seconds]
yeti has quit [Quit: WeeChat 3.0]
yeti has joined #zig
mmohammadi9812 has joined #zig
earnestly has joined #zig
mmohammadi9812 has quit [Ping timeout: 260 seconds]
mmohammadi9812 has joined #zig
meatcar has quit [Quit: bye bye.]
meatcar has joined #zig
redj has joined #zig
amk has quit [Remote host closed the connection]
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
leon-p has joined #zig
xackus has joined #zig
<pixelherodev> Hmm, var decls can exist without the `= Expr`?
<pixelherodev> I thought that `= undefined;` was necessary, at a minimum?
frett27 has joined #zig
<ikskuh> pixelherodev: "extern var foo: u32;"
<pixelherodev> Ahh, right, makes sense :)
mmohammadi9812 has quit [Ping timeout: 246 seconds]
mmohammadi9812 has joined #zig
mmohammadi9812 has quit [Ping timeout: 246 seconds]
mmohammadi9812 has joined #zig
frett27_ has joined #zig
_fritchie has quit [Remote host closed the connection]
_fritchie has joined #zig
frett27 has quit [Ping timeout: 272 seconds]
mmohammadi9812 has quit [Ping timeout: 272 seconds]
mmohammadi9812 has joined #zig
<ed_t> why are option pointer null de references not catchable?
mmohammadi9812 has quit [Ping timeout: 240 seconds]
mmohammadi9812 has joined #zig
<dutchie> because you can use `orelse` or `if (optional) |value|` instead
mmohammadi9812 has quit [Ping timeout: 272 seconds]
<ed_t> so how would that work with while (i.?.field) {...
<ed_t> so how would that work with while (i.?.*.field) {...
mmohammadi9812 has joined #zig
<semarie> ed_t: it should be: while (i) |value| { value.field }
<ed_t> what I want to do is catch a null de reference without a panic
ColonelPhantom has joined #zig
<ed_t> it would would if I could use orelse on expressions like: const c = i.?.* orelse
<ed_t> but zig complains that the type is not an optional pointer, instead of realizing that the express contains one
SimonN has quit [Remote host closed the connection]
SimonNa has joined #zig
<ed_t> eg this fails to: if (i.?.*) |c| {}
<ed_t> with the same type error as the orelse
<dutchie> ed_t: you'd do `if (i) |p|` and then dereference p inside the block if you need to
<ed_t> what i have been doing, since it leads to more readable code is: while (i != null and (i.?.*.p.x != p.x or i.?.*.p.y != p.y))
<ed_t> I was tring to zigify it
<ed_t> and remove the repeated i.?.* in while body too
<dutchie> you can do something like `while (i) |j| while (j.p.x != p.x or j.p.y != p.y) { ... };`
<dutchie> (note the trailing ; is necessary there for the one-statement while)
<ed_t> and when i is null the outer loop exits? (I was thinking think about too)
waleee-cl has joined #zig
seadragon-droid has joined #zig
xackus has quit [Ping timeout: 260 seconds]
<seadragon-droid> Does anyone know of a write-up that explains some of the differences of the Zig comptime vs. run-time semantics?
<seadragon-droid> I'm thinking specifically about SpexGuy's comment here: https://github.com/ziglang/zig/issues/5893#issuecomment-663203324
<dutchie> ed_t: yeah
frett27_ has quit [Ping timeout: 272 seconds]
Akuli has joined #zig
<ed_t> dutchie once again thanks
<ed_t> wierd that I cannot do: while (i) but must include the |c| which ends up creating a const I just use once...
<ed_t> unless i use while (i == null)
<ed_t> that should be not equals
cole-h has joined #zig
ColonelPhantom has quit [Quit: Vision[0.10.3]: i've been blurred!]
gonz_ has quit [Read error: Connection reset by peer]
gonz_ has joined #zig
mmohammadi9812 has quit [Ping timeout: 260 seconds]
mmohammadi9812 has joined #zig
mmohammadi9812 has quit [Ping timeout: 264 seconds]
frett27_ has joined #zig
Stephanie has quit [Quit: Fuck this shit, I'm out!]
Stephie has joined #zig
craigo_ has joined #zig
blueberrypie has quit [Remote host closed the connection]
dch has quit [Ping timeout: 260 seconds]
betawaffle has quit [Ping timeout: 260 seconds]
blueberrypie has joined #zig
betawaffle has joined #zig
xackus has joined #zig
dch has joined #zig
craigo has quit [Ping timeout: 260 seconds]
wootehfoot has joined #zig
mmohammadi9812 has joined #zig
xackus has quit [Ping timeout: 258 seconds]
xackus has joined #zig
seadragon-droid has quit [Quit: Ping timeout (120 seconds)]
cole-h has quit [Ping timeout: 240 seconds]
a_chou has joined #zig
seadragon-droid has joined #zig
wootehfoot has quit [Read error: Connection reset by peer]
seadragon-droid has quit [Quit: Connection closed]
xackus has quit [Ping timeout: 265 seconds]
xackus has joined #zig
travv0 has left #zig [#zig]
leon-p has quit [Ping timeout: 240 seconds]
leon-p has joined #zig
Patrice_ has joined #zig
frett27_ has quit [Ping timeout: 272 seconds]
gazler_ has joined #zig
gazler has quit [Ping timeout: 240 seconds]
riba has joined #zig
a_chou has quit [Quit: a_chou]
shurane has quit [Read error: Connection reset by peer]
shurane has joined #zig
jokoon has joined #zig
kchambers has joined #zig
frett27_ has joined #zig
Patrice_ has quit [Ping timeout: 272 seconds]
xackus has quit [Ping timeout: 265 seconds]
amk has joined #zig
dom96 has joined #zig
dom96 has quit [Changing host]
marijnfs has quit [Quit: WeeChat 2.8]
xackus has joined #zig
jukan has quit [Ping timeout: 264 seconds]
<ed_t> zig's expressions have some wierd limits,
<ed_t> for instance var x:32 and later x/2 fails and you have to do @divTrunc making the code harder to read
<ed_t> and divide throws way some info...
<ed_t> thats x:i32
<ed_t> or with var x:u32 and later i<<(x+x) fails
<ikskuh> ed_t: what's the correct way for integer division?
<ikskuh> it's clear for unsigned ints, but it's not clear for signed division
<ed_t> in 40+ years of coding I have never seen a problem dividing signed ints
<ikskuh> happy you :D
<ed_t> using many many langs
<ikskuh> what mode did they use? trunc, floor or ceiling? ;)
<ed_t> you just need to understand what you are doing (2complement, 1complement) drop the bits. If i want rounding up or down I will take care of it...
jokoon has quit [Quit: Leaving]
<ed_t> try coding on a cad program in forth using 64 bit int doing intergrated circuit design...
earnestly has quit [Quit: WeeChat 3.1-dev]
hnOsmium0001 has joined #zig
zags has joined #zig
<zags> Docs says @as "is the preferred way to convert between types, whenever possible.
<zags> so should I use that instead of @intCast for casting between integer types too?
<dutchie> if you can use @as you should, but it won't work for potentially-lossy integer casts
<dutchie> i.e. shrinking widths or going from signed -> unsigned
<dutchie> then you have to LBYL and use @intCast
<zags> this is only about converting integer and float literals to specific types
<dutchie> then @as should always work (or fail at compile time)
<zags> cool, i'm writing a bunch of U32, U64, etc wrappers as I have a ton of literals of various sizes and I'm not doing the verbose cast on all of them :d
<zags> pub fn U64(comptime val: comptime_int) u64 { return @as(u64, val); }
<zags> ^ pretty much a bunch of those so I can write U64(5) :D
<zags> which makes fmt complain because it's not camelCase, and proper case clashes with the type :D
<zags> s/fmt/zls
<zags> interesting that 3.0 converts to comptime_int, but not 3.x, seems inconsistent even if it's safe
<Gliptic> is there any suggestion to add explicitly typed integer literals, because I find @as clunky
reductum has joined #zig
<zags> i'll push up a lib with those wrappers if peeps wanna use them until (if) std gets them
<andrewrk> Gliptic, I recognize that @as feels clunky but it's not supposed to
<zags> sometimes there's lots of literals :D
frett27_ has quit [Ping timeout: 272 seconds]
<andrewrk> it's pretty rare to need a typed integer literal
<andrewrk> for initializing a struct or array, or a function call, the int literal will be automatically coerced
<andrewrk> and var decls can be annotated with types
<Gliptic> fair enough, I do appreciate that there's a "cast" that doesn't destroy information, most languages don't even have it
<Gliptic> I find that a major shortcoming in Rust, which is very strict about e.g. array indexes being usize, but "as" casts is the only way to convert
<zags> my use case that I've bit fiddling code that shifts and masks, so I'm using the wrappers to make that readable
<zags> other than that, i don't mind @as
<Gliptic> yeah, same here
<Gliptic> although I just use @as
riba has quit [Ping timeout: 240 seconds]
<andrewrk> zags, you may be interested in std.math.shl / std.math.shr as well as this proposal: https://github.com/ziglang/zig/issues/7605
<zags> andrewrk: good point, I'm just converting C++ code so step 1 is making it work. That looks interesting, thanks!
<zags> a potentially stupid idea: a lot of structs will have open/close, allocate/free, etc pairs. Would it make sense to allow tagging those as opening and closing resources? It would be optional and have no effect other than enabling potentially powerful static analysis. If you called open but don't call close, something fishy is going on.
Akuli has quit [Quit: Leaving]
<zags> could take scopes and escape analysis into account I suppose
<zags> something like `pub fn open(path: []const u8) !WindowsDynLib ~close {`
* zags dodges bullets
<zags> lol, wonderful :D
<Gliptic> that's very nice
<zags> very very nice
<andrewrk> it's unlikely to be accepted
<andrewrk> don't get your hopes up
<andrewrk> ifreund, check it out, the capacityInBytes function for MultiArrayList, written cleanly using SIMD: https://clbin.com/yNMnH
<andrewrk> arguably it's cleaner than the non SIMD version. here are both side by side for comparison: https://clbin.com/OsZui
<zags> andrewrk: do you think static analysis will ever be powerful enough to catch our forgot-defer mistakes, or is that an open problem/not solvable/nonhalting/etc ?
<andrewrk> not solvable because it may be intentional
<Gliptic> arena allocators etc.
<zags> yeah, it would need some sort of demarkation I guess
amk has quit [Remote host closed the connection]
amk has joined #zig
reductum has quit [Quit: WeeChat 3.0]