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/
kwilczynski has quit []
waffle_ethics has joined #zig
waffle_ethics has quit [Ping timeout: 256 seconds]
reductum has joined #zig
leon-p has quit [Quit: leaving]
dvaun has joined #zig
craigo has joined #zig
mgxm_ has joined #zig
mgxm has quit [Quit: ....]
mgxm_ is now known as mgxm
fputs has joined #zig
evbo has quit [Ping timeout: 260 seconds]
jukan has joined #zig
jukan_ has quit [Ping timeout: 264 seconds]
craigo_ has joined #zig
notzmv has quit [Remote host closed the connection]
midgard_ has joined #zig
travv0_ has joined #zig
midgard has quit [Ping timeout: 256 seconds]
travv0 has quit [Ping timeout: 256 seconds]
ave_ has quit [Read error: Connection reset by peer]
travv0_ is now known as travv0
ave_ has joined #zig
craigo has quit [Ping timeout: 256 seconds]
squeek502 has joined #zig
notzmv has joined #zig
oats has quit [Quit: until later, my friends]
oats has joined #zig
wilsonk__ has quit [Quit: Leaving]
reductum has quit [Quit: WeeChat 3.0]
knebulae has quit [Read error: Connection reset by peer]
knebulae has joined #zig
earnestly has quit [Ping timeout: 268 seconds]
GrooveStomp has quit [Ping timeout: 264 seconds]
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
wilsonk has joined #zig
nycex- has quit [Quit: Quit]
nycex has joined #zig
earnestly has joined #zig
factormystic has quit [Read error: Connection reset by peer]
factormystic has joined #zig
hspak has joined #zig
drvirgilio has quit [Ping timeout: 258 seconds]
drvirgilio has joined #zig
gazler_ has joined #zig
gazler has quit [Ping timeout: 272 seconds]
waleee-cl has quit [Quit: Connection closed for inactivity]
earnestly has quit [Ping timeout: 246 seconds]
gazler__ has joined #zig
factormystic2 has joined #zig
ave_9 has joined #zig
euantorano_ has joined #zig
gazler_ has quit [Ping timeout: 264 seconds]
euantorano has quit [Ping timeout: 256 seconds]
euantorano_ is now known as euantorano
nycex has quit [Ping timeout: 268 seconds]
wilsonk has quit [Ping timeout: 256 seconds]
factormystic has quit [Ping timeout: 256 seconds]
ave_ has quit [Ping timeout: 256 seconds]
ave_9 is now known as ave_
factormystic2 is now known as factormystic
nycex has joined #zig
decentpenguin has joined #zig
sord937 has joined #zig
koakuma has quit [Read error: Connection reset by peer]
jukan has quit [Ping timeout: 240 seconds]
wilsonk_ has joined #zig
tnorth_ has joined #zig
midgard_ has quit [Ping timeout: 260 seconds]
jukan has joined #zig
ky0ko has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
sebonirc has quit [Read error: Connection reset by peer]
midgard has joined #zig
sebonirc has joined #zig
kbd has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
cole-h has quit [Ping timeout: 272 seconds]
leon-p has joined #zig
earnestly has joined #zig
craigo_ has quit [Ping timeout: 256 seconds]
earnestly has quit [Ping timeout: 256 seconds]
earnestly has joined #zig
lanodan has quit [Quit: WeeChat 2.9]
jokoon has joined #zig
xackus has joined #zig
decentpenguin has quit [Ping timeout: 256 seconds]
jokoon2 has joined #zig
eio__ has joined #zig
jokoon has quit [Ping timeout: 272 seconds]
jokoon2 has quit [Ping timeout: 264 seconds]
craigo_ has joined #zig
waleee-cl has joined #zig
xackus has quit [Read error: Connection reset by peer]
xackus_ has joined #zig
waffle_ethics has joined #zig
oats has quit [Ping timeout: 256 seconds]
oats has joined #zig
<Gliptic> anyone had problems with generated files in builds? I made a custom build step that writes to a .zig file, the .exe build has a dependOn on that step, but weirdly the zig compiler seems to skip one specific line of code in the generated file when it builds (???)
<Gliptic> if I remove the generation from the build.zig and update the timestamp on the existing generated file, it's compiled correctly
vcarvalho has joined #zig
fputs has quit [Quit: Leaving]
<ifreund> Gliptic: I do a lot of code generation in the build.zig with zig-wayland and haven't had any issues
<ifreund> do you have your project online somewhere?
<Gliptic> I'll look at how you do it, thanks
<Gliptic> not yet, but I might scale it down to a testcase if I can't figure this out
<Gliptic> it's always the same point in the file it's skipping, I had a variable declaration there before and then it was complaining about it missing
<Gliptic> don't understand how it can be line-aligned
waffle_ethics has quit [Ping timeout: 264 seconds]
<ifreund> it sounds like a caching issue tbh
<Gliptic> yeah, if I don't do the "touch file", I get the same error even when not regenerating
<ifreund> zig-wayland's code generation overwrites the generated files everytime the build.zig is run
<Gliptic> yeah, that's what I'm doing too
<Gliptic> hm, is wayland-scanner doing the generating
<Gliptic> I write the file directly from Zig
waffle_ethics has joined #zig
dingenskirchen has quit [Quit: ZNC 1.8.1 - https://znc.in]
dingenskirchen has joined #zig
donniewest has joined #zig
<ifreund> Gliptic: wayland-scanner generates some C code I link because of zig issue #131
<Gliptic> ah, there was an @import inside the function I missed
<ifreund> hmm, yeah idk why I put it there :D
<Gliptic> this looks more or less what I'm doing
<Gliptic> I tried to write it first ot an ArrayList and then .writeAll at the end, but same problem
<Gliptic> weird
<ifreund> how you write the files is likely irrelevant
<ifreund> does the build step where you want to use these generated sources depend on the step where you generate them?
<Gliptic> yeah, I wonder if I've accidentally added some weird character or something that is removed when I resave it..
<Gliptic> yes
<Gliptic> and before I just wrote it directly in the build function
<Gliptic> pretty sure that would always happen before the .zig files were compiled, but same error then
<ifreund> hmm not really sure what's happening then. I'm using zig 0.7.1 on linux fwiw
<Gliptic> uh, wait a second, there's a comment above that line..
<Gliptic> yeah, I'm on windows, so might be a newline issue
<Gliptic> oh dammit, that was it..
<Gliptic> using the multiline strings produces \n as newlines, but zig doesn't think that's a newline when compiling on windows apparently?
<Gliptic> so the comment extended onto the next line
<Gliptic> but on other lines I'm using .print() which I guess is converting the \n to \r\n
<ifreund> Gliptic: you could pass it through zig fmt to fix that I suppose
<Gliptic> yeah
<Gliptic> just annoying, tried to figure this out since last night
<Gliptic> zig should error on \n just like it does with \t
<Gliptic> or accept \n
<ifreund> I think you meain \r
<Gliptic> no, \n
<Gliptic> pretty sure there's no \r in there alone
<ifreund> \r\n is windows, \n is unix
<Gliptic> but I'll check exactly what happens
<Gliptic> yes
<Gliptic> actually, when I resave the file becomes all \n
<Gliptic> I suppose it's because there's a mix of line endings
<Gliptic> zig tries to guess which one to look for
<mikdusan> from wikipiedia: lf, crlf, cr (apple II, classic macos, os9), rs (qnx), lfcr (let's be different Acorn and RISC OS), nl (IBM) and non-ascii newline for zx80
stilbruch has quit [Quit: ZNC 1.8.2 - https://znc.in]
stilbruch has joined #zig
vcarvalho has quit [Quit: vcarvalho]
vcarvalho has joined #zig
waffle_ethics has quit [Ping timeout: 256 seconds]
stilbruch has quit [Quit: ZNC 1.8.2 - https://znc.in]
waffle_ethics has joined #zig
stilbruch has joined #zig
eio__ has quit [Quit: Leaving]
stilbruch has quit [Client Quit]
stilbruch has joined #zig
stilbruch has quit [Remote host closed the connection]
stilbruch has joined #zig
Akuli has joined #zig
stilbruch has quit [Quit: goodbye]
stilbruch has joined #zig
stilbruch has quit [Client Quit]
stilbruch has joined #zig
waffle_ethics has quit [Ping timeout: 264 seconds]
<ed_t> error: expected type 'type', found 'i32'
<ed_t> const w:i32 = std.math.sqrt(std.math.powi(cbx-c.p.x,2)+std.math.powi(cby-c.p.y,2))+1;
<ed_t> why?
hnOsmium0001 has joined #zig
<g-w1> read the signature of powi
<ed_t> it raise any value to and integer power
<g-w1> pub fn powi(comptime T: type, x: T, y: T) (error{
<ed_t> then the examples in the docs are deceiving: powi(x, +-0) = 1 for any x
<ed_t> if it needs a type the example should include it
<ed_t> even if its a dummy type
<ed_t> but in any case THANKS
rtpg has quit [Read error: Connection reset by peer]
rtpg has joined #zig
<g-w1> dont use the docs, just read the code. the docs are very bad and are not production ready yet
<ed_t> :-/ not rftm rtfc
waffle_ethics has joined #zig
<g-w1> lol
craigo_ has quit [Quit: Leaving]
evbo has joined #zig
<g-w1> yep, the doc comments are wrong. I think they are just trying to illustrate a point, not provide correct code since +- isn't valid either
<ed_t> g-wl and all the tests for powi use inline values, none use expressions, When I use an expression it complains: error: invalid operands to binary expression: 'std.math.powi.error:27:44!i32'
<g-w1> you must use try
<dutchie> or catch unreachable if you are sure you can't over/underflow
<dvaun> the pow file has some tests which illustrate the over/underflow occurring
<dvaun> `lib/std/math/powi.zig`
<ed_t> with a catch unreachable at the end of the expression (multiple powi and sqtr) I still get the errors
<dutchie> you have to do it for each call
<ed_t> that is a little insane
<ed_t> imho
<dutchie> the function returns an error union, not an integer, so you need to unwrap it every time
<ed_t> its still insane. I care that the expression works. If any part fails with I just want to know the first error.
<ed_t> doing any sort of math in zig is going to be a real pita
<dutchie> that's what try is for
<ed_t> try at the start of the express is not working - still get the same error
<dutchie> `const w = std.math.sqrt(try std.math.powi(i32, cbx-c.p.x, 2) + try std.math.powi(cby - c.p.y, 2)) + 1;` should work
<ifreund> missing the type arg for the second powi call
<dutchie> ifreund: oops ty
<dutchie> irc not a good code editor
<ed_t> error: invalid operands to binary expression: 'std.math.powi.error:27:44!i32' and 'i32'
<ifreund> you need try on both calls
<justin_smith> ed_t: you need to unpack the error type (yeah try would help there)
<dutchie> anyway just for squaring i'd write something like `const dx = cbx - c.p.x; const dy = cby - c.p.y; const w = std.math.sqrt(dx*dx + dy*dy) + 1`
<dutchie> or use std.math.hypot
<dutchie> (though that's only implemented for floats)
<ed_t> yes and the second powi has the i32 now and i still get the error (try on both powi)
kbd has joined #zig
<ed_t> I was tring to avoid temp constants
<g-w1> your error should look like this error:linenum:col. use the col to see where you went wrong
<ed_t> g-wl its pointing to the powi just after the first powi
<ed_t> decomposing the second try causes the problem sqrt(try powi) works, sqrt(try powi + try powi) fails
earnestly has quit [Ping timeout: 256 seconds]
earnestly has joined #zig
<dutchie> is this some dumb operator precedence thing
<g-w1> yes probably
<dutchie> try isn't in https://ziglang.org/documentation/master/#Precedence but + binds tighter than catch
<dutchie> so it's probably parsing it as `try (powi + try powi)` not `(try powi) + (try powi)`
<ed_t> brackets help
<ed_t> thanks - this works: std.math.sqrt((try std.math.powi(i32,cbx-c.p.x,2))+(try std.math.powi(i32,cby-c.p.y,2)))+1;
<dutchie> i'd definitely factor that out into some sub-expressions in local variables and trust the optimiser to sort it out for me
<justin_smith> dutchie: optimizations is about having fewer lines of code, and the more calculation you do in one line the more optimizeder it is
<Gliptic> no no, fewer characters
<Gliptic> so you should shorten the variable names more
<justin_smith> (in all seriousness I wouldn't expect turning a sub expression into a local to even have a cost in most cases)
<dutchie> indeed, since it's going to have to store the result of that subexpression somewhere anyway
<justin_smith> precisely
<Gliptic> in a language like C++, it might limit the reordering of operations if the functions have side-effects (or if it can't prove they don't)
<fengb> Pretty sure LLVM IR introduces intermediates if you don't explicitly define it
<fengb> Since operations can only be 1 thing at a time
<justin_smith> Gliptic: if your std.math.pow has side effects, you're already screwed :D
<Gliptic> in (a+b), C++ is allowed to evaluate b then a
<Gliptic> justin_smith: yeah, I'm pretty sure it doesn't matter for pow
<Gliptic> but it at least requires some non-trivial check for a C++ compiler to know it can swap them if beneficial
<justin_smith> Gliptic: but can't c++ also reorder the assignments if you break it out?
<Gliptic> nope
<justin_smith> got it
<dvaun> So unwrap with `catch <some-default>` or just use `try`
<dvaun> > An error set type and a normal type can be combined with the ! operator to form an error union type. Values of these types may be an error value, or a value of the normal type.
<Gliptic> the , or ; is a sequence point (well, they call it something else now I think)
<Gliptic> I mean, if it can see that there aren't side-effects, it can reorder them of course
<Gliptic> because that follows the "as if" rule
<justin_smith> dvaun: or sometimes even if with a |binding|
<dvaun> i guess that would be needed fto check for underflow or overflow right?
<justin_smith> Gliptic: that "as if" and its effect on multi threaded memory access whas what I was remembering
<justin_smith> where the memory storage is treated as not having side effects, but in terms of shared memory access acts like an unpredictable side effect
<Gliptic> that's down to the memory model
<justin_smith> (or that was my weird mental model of the whole thing at least)
<Gliptic> what counts as "as if" or not
<justin_smith> yeah
<pixelherodev> I think PrimaryTypeExpr is a bad name in the grammar, given that every valid PrimaryTypeExpr is a valid Expr...
<pixelherodev> Rather, since PrimaryTypeExprs don't have to represent types
<motiejus> hi all. I am trying to add a correct `-print-prog-name=ld` to zig, so it returns the appropriate linker for autotools. I am now struggling to relate the incoming args in `main.zig` to the appropriate linker (ld.lld/ld64.lld/lld-link/wasm-ld). I presume it should be resolved from `-target` somehow; any pointers?
<motiejus> related question -- looks like `zig ld.lld --target=x86_64-linux-musl" is not a thing; I assume ld.lld is not supposed to be passed in target as its first param?
bitmapper has quit [Quit: Connection closed for inactivity]
waleee-cl has quit [Quit: Connection closed for inactivity]
<motiejus> I think I found the answer to the first question -- `getObjectFormat(Target)`, second question remains :)
<g-w1> what are you trying to do for the second one?
<g-w1> build-lib or build-exe will link stuff when passed obj files
<motiejus> I am trying to compile xz with `zig cc` and autotools
<g-w1> so use `zig build-lib` to link
kbd has quit [Quit: Textual IRC Client: www.textualapp.com]
<motiejus> and it fails at linking step, but I didn't the root cause yet
<g-w1> hmm, what is the error
<motiejus> trying `LD="zig build-lib"` now
<motiejus> didn't help. Nothing specific, fails even before libtool: https://paste.mozilla.org/mDGjX17h
<motiejus> see the `false cr <...>`? I am not experienced with libtool, but I think that's bad :)
<motiejus> it's trivial to reproduce -- download xz archive, do `CC="zig cc" LD="zig build-lib" ./configure && make -j$(nproc)` on a somewhat fresh linux installation (debian:buster docker image works well)
<motiejus> the only dependency then is make and zig itself (extracted from a nightly tarball)
<motiejus> for the curious
xackus_ has quit [Ping timeout: 246 seconds]
<dvaun> maybe export CC to `zig cc`
sebonirc has quit [Ping timeout: 256 seconds]
<motiejus> export vs non-export doesn't matter; configure picks it up
wootehfoot has joined #zig
wootehfoot has quit [Read error: Connection reset by peer]
kwilczynski has joined #zig
<motiejus> ok, found it: it was missing `AR`. Now with `AR="zig build-lib" LD="zig build-lib" CC="zig cc"` it is failing, because `zig build-lib cr <...>` is not a valid option, though it is for gnu ar
<motiejus> i.e. `zig build-lib` does not understand `cr` command intended for ar
evbo has quit [Read error: Connection reset by peer]
frett27 has joined #zig
evbo has joined #zig
jukan_ has joined #zig
jukan has quit [Ping timeout: 240 seconds]
blackbeard420 has quit [Quit: ZNC 1.8.0 - https://znc.in]
blackbeard420 has joined #zig
waleee-cl has joined #zig
ur5us has joined #zig
xackus_ has joined #zig
waffle_ethics has quit [Ping timeout: 272 seconds]
cole-h has joined #zig
<ed_t> how would you define a constant array of stings, eg a[0]="somestring" etc
tnorth_ has quit [Ping timeout: 260 seconds]
waffle_ethics has joined #zig
earnestly has quit [Ping timeout: 240 seconds]
earnestly has joined #zig
waffle_ethics has quit [Ping timeout: 256 seconds]
r0bby has quit [Ping timeout: 264 seconds]
r0bby has joined #zig
xackus__ has joined #zig
xackus_ has quit [Read error: Connection reset by peer]
<ugla> const some_strings = [_][]const u8{"some string", "some other string"};
<ed_t> thanks ugla
<ed_t> can the type be for i? for (xxx) |y, i|
<ugla> I think so
<ed_t> if so I cannot figure out how i32:i fails i:i32 fails
<justin_smith> ed_t: are you asking why i can't be i32 in "for (xxx) |y, i|" ?
<justin_smith> I think i is always usize(?) but when I need iN I use @intCast(iN, i)
Akuli has quit [Quit: Leaving]
sord937 has quit [Quit: sord937]
vcarvalho has quit [Quit: WeeChat 2.9]
frett27 has quit [Ping timeout: 240 seconds]
Snetry- has quit [Ping timeout: 265 seconds]
donniewest has quit [Quit: WeeChat 3.0]
xackus_ has joined #zig
squeek502 has quit [Remote host closed the connection]
xackus__ has quit [Read error: Connection reset by peer]
squeek502 has joined #zig
blueberrypie has quit [Quit: Ping timeout (120 seconds)]
blueberrypie has joined #zig
xentec_ has joined #zig
xentec has quit [Quit: memento mori]
ur5us_ has joined #zig
Snetry has joined #zig
ur5us has quit [Remote host closed the connection]
hnOsmium0001 has quit [Read error: Connection reset by peer]
jzelinskie has quit [Ping timeout: 260 seconds]
ovf has quit [Disconnected by services]
jzelinskie_ has joined #zig
eddyb[legacy] has quit [Ping timeout: 264 seconds]
eddyb[legacy] has joined #zig
ovf has joined #zig
hnOsmium0001 has joined #zig
nvmd has quit [Quit: Later nerds.]