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/
isolier has quit [Quit: isolier]
v0idify has quit [Remote host closed the connection]
isolier has joined #zig
v0idify has joined #zig
rom1504 has quit [Ping timeout: 272 seconds]
rom1504 has joined #zig
powerofzero has joined #zig
<qbit> does anyone have an example of a build.zig that does native and cross compile ?
<qbit> oh.. -Dtarget :D
<g-w1> you can also set the target if you want it to be different in build.zig
<qbit> sweet
<qbit> my grand plan won't work anyway.. seems macos' SDL stuff is too different to openbsd
<qbit> trying to compile zig-gorillas on openbsd so i can plan it on my m1 (in rosetta)
isolier has quit [Quit: isolier]
isolier has joined #zig
notzmv has joined #zig
brzg has joined #zig
craigo has joined #zig
decentpenguin has quit [Ping timeout: 245 seconds]
decentpenguin has joined #zig
Techcable has quit [Quit: ZNC - https://znc.in]
ur5us_ has joined #zig
brzg has quit [Quit: leaving]
powerofzero has quit [Ping timeout: 265 seconds]
powerofzero has joined #zig
ur5us_ has quit [Ping timeout: 264 seconds]
bitmapper has joined #zig
<daurnimator> g-w1: I wrote a terminfo parser
<g-w1> in zig? I saw the lua one :)
<daurnimator> g-w1: yes
<daurnimator> infact its a port of my lua one ;)
purpleLizard has joined #zig
<g-w1> can you link :O ?
<daurnimator> I did a little more work on it but didn't push it up
<g-w1> nice :)
powerofzero has quit [Ping timeout: 246 seconds]
squeek502 has quit [Remote host closed the connection]
gazler has joined #zig
gazler_ has quit [Ping timeout: 265 seconds]
xackus has joined #zig
xackus__ has quit [Ping timeout: 265 seconds]
cbix is now known as fh
fh is now known as cbix
cbix is now known as fh
fh is now known as cbix
cbix is now known as fh
fh is now known as cbix
cbix is now known as fh
Techcable has joined #zig
fh is now known as cbix
Techcable has quit [Quit: Techcable - The Lounge]
Techcable has joined #zig
_whitelogger has joined #zig
earnestly has quit [Ping timeout: 256 seconds]
purpleLizard has left #zig ["Konversation terminated!"]
cole-h has quit [Ping timeout: 276 seconds]
decentpenguin has quit [Quit: ZNC crashed or something]
decentpenguin has joined #zig
xackus has quit [Ping timeout: 256 seconds]
bitmapper has quit [Quit: Connection closed for inactivity]
waleee-cl has quit [Quit: Connection closed for inactivity]
<mikdusan> andrewrk: "simplest" option to start publishing zig-macos-aarch64 tarballs is to:
<mikdusan> - add another azure job on x86_64 macos-10.15 vm
<mikdusan> - use xcode-12.4 or higher (it's available) to produce arm64 target
<mikdusan> - built against a llvm+clang+lld that I can spin pretty quickly with arm64 arch target
<mikdusan> negatives:
<mikdusan> - no zig build test ability for the ci process
dyeplexer has joined #zig
<mikdusan> - not built using a zig-boostrap process. we can't do that style (even with system-linker-hack) without changing how zig build-exe and zig cc drivers strips the command-line when it thinks we're cross-compiling
<mikdusan> also though, zig-bootstrap is, as far as I can tell, broken for x86_64 macos host too. And in order to fix (continue using zig cc/c++) we only have 2 choices: wait for zld and/or improve system-linker-hack enough to get zig-bootstrap working.
<mikdusan> thoughts?
ur5us_ has joined #zig
shirty has joined #zig
sord937 has joined #zig
shirty has quit [Client Quit]
_whitelogger has joined #zig
mtiljeset[m] has quit [Quit: Idle for 30+ days]
craigo has quit [Ping timeout: 256 seconds]
craigo has joined #zig
hidayat has joined #zig
hidayat has quit [Client Quit]
ur5us_ has quit [Ping timeout: 240 seconds]
ifreund has joined #zig
zupss has joined #zig
ur5us_ has joined #zig
craigo has quit [Remote host closed the connection]
craigo has joined #zig
earnestly has joined #zig
ur5us_ has quit [Ping timeout: 240 seconds]
kbd has joined #zig
<kbd> So, one can say: `var foo = if(true) "T" else "F";`. Is it possible to use blocks in place of "T"/"F", returning a value from the blocks?
leon-p has joined #zig
<ifreund> sure
<ifreund> if (true) blk: { break :blk 5; } else 4;
<kbd> ok: var result = if (flag) b1: { break :b1 "truthy"; } else b2: { break :b2 "falsy"; }; Thanks ifreund.
tane has joined #zig
johannes_ has joined #zig
johannes_ is now known as kenran
xackus has joined #zig
ifreund1 has joined #zig
ifreund2 has joined #zig
gpanders has quit [Remote host closed the connection]
ifreund has quit [Disconnected by services]
ifreund2 is now known as ifreund
gpanders has joined #zig
ifreund1 has quit [Ping timeout: 264 seconds]
mjanssen has joined #zig
<mjanssen> I know I can make build a dynamic library from the command line with zig build-lib -dynamic. Is there any way to pass the -dynamic from build.zig ?
<ifreund> pretty sure addSharedLibrary() passes that by default
kenran has quit [Ping timeout: 256 seconds]
<mjanssen> I tried that, but that requires a version and then failes with a file not found
<mjanssen> removing zig-cache fixed that
<mjanssen> so works with addSharedLibrary, thanks
<ifreund> mjanssen: you can use .unversioned if your use-case doesn't require a version
<mjanssen> ifreund: thanks
<mjanssen> it does require a version, so that's OK. Any easy way to pass the version from build.zig to the actual zig code?
<ifreund> addBuildOption()
<ifreund> then you can @import("build_options"); in your code
<mjanssen> ah great thanks
* mjanssen working on a basic Tcl/Tk dynamic library
txdv has joined #zig
<txdv> random.init needs a seed, how do I randomly generate a seed? :D
dyeplexer has quit [Ping timeout: 276 seconds]
<daurnimator> huh... what happended to the AT_RANDOM code?
<ifreund> daurnimator: see the discussion on the PR
<daurnimator> ifreund: which bit?
<ifreund> daurnimator: starting with jediscat1's comment I guess
eax has joined #zig
<daurnimator> ifreund: mmm. I agree with andrew's initial comment
<daurnimator> I might throw up a PR bringing it back; but without the downside
<ifreund> I don't have a strong opinion one way or the other, haven't looked closely enough myself for that
<ifreund> currently fixing more things we broke in #7920 :D
<txdv> That rewrite was huge
<mjanssen> any prefered paste site?
<daurnimator> mjanssen: zig.godbolt.org
dyeplexer has joined #zig
wilsonk_ has joined #zig
wilsonk has quit [Remote host closed the connection]
<mjanssen> trying to translate a working zig build-lib to zig build. Fails with an unreachable code error: https://zig.godbolt.org/z/n6Te5h
<ifreund> I see that you're using 0.6.0, you probably want to be using 0.7.1 if not master
<mjanssen> this was with 0.7.0
<mjanssen> but I can try with master
<mjanssen> ah using 0.6.0 lib
<ifreund> you have to use the same library version as compiler version
<mjanssen> same error if I remove the system zig and it uses the lib of the compiler
<mjanssen> I can try with master
<ifreund> mjanssen: it would help to see your build.zig and the working zig build-lib command
Ashpool has quit [Remote host closed the connection]
<mjanssen> t's in the paste
<mjanssen> in the comments
<mjanssen> lib.linkSystemLibrary("tclstub8.6"); seems to be the offending line
<ifreund> I don't think you should need addLibPath there
<ifreund> you could try linkSystemLibraryName instead of linkSystemLibrary to bypass pkg-config
<mjanssen> indeed addLibPath is not needed
kbd has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
<mjanssen> and changing to linkSystemLibraryName works
ubert1 has joined #zig
eax has quit [Ping timeout: 268 seconds]
johannes_ has joined #zig
eax has joined #zig
<mjanssen> thanks ifreund. Build works now
<ifreund> nice :)
bitmapper has joined #zig
<mjanssen> I have two vars, a,b with types [*c]const u8,comptime_int . I expect if (a!=b) { ... } to be a type error but it's not. Am I missing something?
<daurnimator> mjanssen: `[*c]` is a C pointer
<daurnimator> mjanssen: they intentionally work like C pointers... which includes the ability to coerce to an integer I guess
<mjanssen> hmm ok some playing aroundseems to confirm this
<mjanssen> good to know
<daurnimator> though looking closer it might be a bug...
<daurnimator> `@TypeOf([*c]const u8, comptime_int)` seems to return `type`
<mjanssen> maybe for the wasm target only? I get a different result if I test it on my machine
craigo has quit [Ping timeout: 260 seconds]
<qbit> does zig have something similar to 'go fmt' ?
<Nypsie> zig fmt :)
supercoven has joined #zig
<qbit> awesome
<qbit> ty :D
<Nypsie> np. There's also a language server like gopls if that's something you use.
<qbit> it is!
<Nypsie> In that case: https://github.com/zigtools/zls (It requires master but not newer than like 3 weeks ago)
<qbit> sweet - ty
<Nypsie> np :)
ubert1 has quit [Ping timeout: 260 seconds]
kenran has quit [Ping timeout: 260 seconds]
kenran has joined #zig
cole-h has joined #zig
gju has joined #zig
powerofzero has joined #zig
dddddd has quit [Ping timeout: 256 seconds]
dddddd has joined #zig
powerofzero has quit [Ping timeout: 264 seconds]
kenran has quit [Quit: leaving]
zags has joined #zig
<tane> building ZLS is such a pita
notzmv has quit [Ping timeout: 264 seconds]
jah has joined #zig
arielp has joined #zig
<Nypsie> Why?
waleee-cl has joined #zig
<tane> I can't see what version of zig it is programmed against
<tane> the docs claim I need the master of zig, but errors if I do that
sord937 has quit [Quit: sord937]
cole-h has quit [Ping timeout: 246 seconds]
zags_ has joined #zig
<tane> ah I see you have just been talking about ZLS lol
<tane> what I said wasn't related to that :)
zags has quit [Read error: Connection reset by peer]
<Nypsie> It is programmed against master. But master is such a fast moving target that it's hard to keep up. 1 - 2 weeks ago a PR was merged that completely revamped the AST that ZLS uses as well. ZLS hasn't been updated to reflect that change just yet (There's an open PR for it, but as you can see, 5k loc and it's still WIP :))
<Nypsie> Aaah ok :)
<tane> yes, I see
eax has quit [Quit: eax]
<tane> I wouldn't have changed anything if it hadn't stopped providing completions muh
zags_ has quit [Ping timeout: 256 seconds]
zags has joined #zig
<tane> at least it doesn't complete "std."
<Nypsie> You sure you set std's path correctly in zls.json?
powerofzero has joined #zig
<tane> I am now sure that it wasn't set correctly
<tane> thanks for the pointer - I don't remember setting it ever but I'm confident that it worked before Oo
<Nypsie> No problem and who knows haha :D
Akuli has joined #zig
<Nypsie> andrewrk: Any reason why an inferred errorset return type has the tag `identifier` rather than `error_union`. Is this a regression, or should I manually check if the return type of a function is an inferred error set or an explicit error_union. This is regarding the AST refactoring.
<ifreund> hmm? Inferred error sets don't have any token, fn foo() !void is what you're talking about right?
<Nypsie> Correct
<Nypsie> Ah I should've checked if there was a token for it. In the old format the return type of a function was a union, so it was easy to check if it was an inferred error set or not.
<ifreund> the node for the return type will have tag error_union I'm pretty sure
<Nypsie> Nope, only when I do fn foo() anyerror!void
<ifreund> oh yeah, we only use that for explicit error sets to save memory
<Nypsie> Aaah ok
<ifreund> that way we can have fewer nodes
<Nypsie> Thanks for confirming :)
<Nypsie> I'll have to manually check for it in zls then
<Nypsie> (I should've checked render.zig before asking. There's literally a line with: `const maybe bang = ....`
<Nypsie> Sorry for wasting you guys time
r0bby has quit [*.net *.split]
fireglow has quit [*.net *.split]
drvirgilio has quit [*.net *.split]
oats has quit [*.net *.split]
raggi has quit [*.net *.split]
kwilczynski has quit [*.net *.split]
dutchie has quit [*.net *.split]
jzelinskie has quit [*.net *.split]
dputtick has quit [*.net *.split]
nikki93 has quit [*.net *.split]
karrick has quit [*.net *.split]
rtpg has quit [*.net *.split]
tcsc has quit [*.net *.split]
guan has quit [*.net *.split]
oats has joined #zig
<ifreund> no worries!
karrick has joined #zig
kwilczynski has joined #zig
rtpg has joined #zig
tcsc has joined #zig
dputtick has joined #zig
jzelinskie has joined #zig
dutchie has joined #zig
guan has joined #zig
fireglow has joined #zig
r0bby has joined #zig
copy has joined #zig
raggi has joined #zig
greaser|q has joined #zig
nikki93 has joined #zig
nikki93 has quit [Changing host]
nikki93 has joined #zig
r0bby has joined #zig
r0bby has quit [Changing host]
r0bby has quit [Max SendQ exceeded]
posixlix has quit [Ping timeout: 240 seconds]
r0bby has joined #zig
drvirgilio has joined #zig
raggi is now known as Guest28388
Snektron has quit [Ping timeout: 258 seconds]
watzon has quit [Ping timeout: 265 seconds]
BitPuffin has quit [Ping timeout: 244 seconds]
tjammer[m] has quit [Ping timeout: 246 seconds]
kameliya[m] has quit [Ping timeout: 246 seconds]
fengb has quit [Ping timeout: 246 seconds]
Nypsie[m] has quit [Ping timeout: 246 seconds]
ifreund_ has quit [Ping timeout: 258 seconds]
<ifreund> Nypsie: actually it's not really an optimization, it's just how the grammar works:
bitonic has quit [Ping timeout: 258 seconds]
<ifreund> FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? CallConv? EXCLAMATIONMARK? (Keyword_anytype / TypeExpr)
siraben has quit [Ping timeout: 268 seconds]
<ifreund> note that fn foo() ! foo!void {} parses but fails semantic analysis
<tane> is there something scanf-like available already?
<Nypsie> Oh I see! Thanks for that
<tane> sscanf to be precise
<ikskuh> tane: not really, how should that look like?
<ikskuh> (i don't consider scanf-api good)
<ikskuh> or in other words: what do you want to achieve?
<ikskuh> convert a string to int?
ugla has quit [Ping timeout: 265 seconds]
<tane> convert "2032-23-12 12:12" to five ints
jaens[m] has quit [Ping timeout: 268 seconds]
<tane> i.e. "%4d-%2d-%2d %2d:%2d"
<ikskuh> ah
<ikskuh> try std.fmt.parseInt(u16, slice[0..4], 10)
<ikskuh> try std.fmt.parseInt(u16, slice[5..7], 10)
<ikskuh> try std.fmt.parseInt(u16, slice[8..10], 10)
<ikskuh> ...
<tane> yeah, ok
<tane> I wonder whether one could construct some type-safe sscanf-like thing with a comptime format string + an anonymous struct/list
<ifreund> definitely possible
<ikskuh> you surely can
<ifreund> there was a PR up for a while but it got stale
<ikskuh> would return either "failure" or a tuple
posixlix has joined #zig
<tane> ah ok cool, I'll keep that one in my list
<tane> I think such a functionality would be really good to have in the stdlib - still enough time :)
<g-w1> it would make parsing things really easy
<tane> " This branch is 3 commits ahead, 1291 commits behind ziglang:master. " :)
<tane> D-lang has something similar called formattedRead that checks everything during comptime
rowbee is now known as rohb
Snektron has joined #zig
<mipri> get it before advent of code and it'll probably get some use. AOC2020 is when https://nim-lang.org/docs/strscans.html got some attention.
<tane> it seems the original PR was motivated by AOC as well :)
<tane> if simple text parsing functions are missing, people tend to whatever is available, e.g. json
<tane> I once participated in an optimization challenge and the instance files were distributed as pretty printed (with 4 space identation) JSON files, resulting in 300mb instance files, although the actual content when presented in a simple text format would be 1MB or so
watzon has joined #zig
kbd has joined #zig
BitPuffin has joined #zig
dyeplexer has quit [Remote host closed the connection]
tjammer[m] has joined #zig
Nypsie[m] has joined #zig
fengb has joined #zig
kameliya[m] has joined #zig
arielp has quit [Ping timeout: 260 seconds]
ugla has joined #zig
Guest28388 is now known as raggi
txdv has quit [Ping timeout: 240 seconds]
bbuccianti has joined #zig
Guest24956 has joined #zig
ifreund_ has joined #zig
bitonic has joined #zig
siraben has joined #zig
supercoven has quit [Ping timeout: 245 seconds]
jaens[m] has joined #zig
eax has joined #zig
craigo has joined #zig
powerofzero has quit [Ping timeout: 245 seconds]
arielp has joined #zig
powerofzero has joined #zig
Guest24956 is now known as zmv
zmv is now known as notzmv
zags has quit [Ping timeout: 265 seconds]
<tane> I think the PR for std.fmt.scan should be redone, I guess returning !usize for the number of matched items would be nice and the typ annotations in the format aren't necessary, only width modifiers etc
<bbuccianti> how do you alloc on zig?
<bbuccianti> I want to have a runtime sized array like thing
powerofzero has quit [Ping timeout: 264 seconds]
powerofzero has joined #zig
<bbuccianti> thanks, dutchie !
zags has joined #zig
ur5us_ has joined #zig
blackpawn has joined #zig
<oats> andrewrk, good luck on your last "leg" :P
<v0idify> if (num == 0) @intCast(u8, 0) else @intCast(u8, 5) // ALWAYS yields 0
<ifreund> 1. use @as() not @intCast() there
<ifreund> 2. gonna need more context to help further :P
<v0idify> can't really give context sorry :#
<g-w1> is num ever not 0?
<v0idify> yes
<v0idify> var a: u8 = 5; if (num == 0) a = 0; // then use a
<v0idify> works fine
<v0idify> thanks for the @as thing :#
<ikskuh> v0idify: why can't you share more context?
<ikskuh> right now, there are some bugs related to condition evaluation in stage1
<ikskuh> that require more context to tell you if it works or not
<v0idify> num is a value in a struct taken from for(list.items) |struct|
<v0idify> what kind of context do you need? it's "private" source code
<v0idify> num is an u32
<ifreund> I'm not going to be able to be useful without seeing more, ideally all of the source code
<v0idify> sorry :|
<ifreund> hey, it's your loss not mine /shrug
<v0idify> true
<v0idify> i have good reasons i promise :)
<g-w1> v0idify: can you at least say what type num is?
<g-w1> it doesn't repro for me :/
<zags> hm, can I swapRemove while iterating?
<zags> (hashmap)
<ifreund> zags: if you mean the ArrayHashMap sure
<ifreund> (see the doc comment)
<zags> thanks
<zags> AutoArrayHashMap specifically, it was clear from the comments on that one
<v0idify> g-w1, u32, i haven't tried making a mvp
<g-w1> ok, i cant really help you
<v0idify> it's fine
<s-ol> how can i go from a string literal to a zero-terminated fixed-size [N]u8 array?
<s-ol> i'm interacting with a C api with fixed-size string fields in structs
<s-ol> error: expected type '[128]u8', found '*const [15:0]u8'
<ifreund> s-ol: dereference the string literal and pad with 0s
<ifreund> "foo".* ++ ([1]u8{0} **)
<ifreund> ** 100 - "foo".len I mean
arielp has quit [Ping timeout: 264 seconds]
Akuli has quit [Quit: Leaving]
<s-ol> oof, ok
<s-ol> guess ill put that in a little wrapper fn then
<zags> ifreund: .registered = std.ArrayList(*Expr).init(allocator)
<zags> oops
<s-ol> or maybe i can adjust the types on the other side
<zags> iterating arraylist and doing swapRemove seems to run into issues. I guess I should put items scheduled for removal in a separate array and delete that after the loop?
eax has quit [Ping timeout: 268 seconds]
<s-ol> hm, and now im struggling ahrd to produce an empty '[*]const [*:0]const u8'
<s-ol> actually... that just means its typed wrong right
<s-ol> it should be a 0-element array as a C pointer, so it could be literally any value or null
arielp has joined #zig
nvmd has quit [Quit: Later nerds.]
<ifreund> hmm, &[_]u8{} perhaps?
riba has joined #zig
tane has quit [Quit: Leaving]
arielp has quit [Ping timeout: 260 seconds]
powerofzero has quit [Ping timeout: 264 seconds]
cole-h has joined #zig
kbd has quit [Quit: Textual IRC Client: www.textualapp.com]
<s-ol> ifreund: ill try it tomorrow
<s-ol> if anyone is into VR, this seems to work now (!!): https://github.com/s-ol/openxr-zig
<s-ol> (im waiting for my valve index to arrive, time to set up the toolchain ;)
powerofzero has joined #zig
notzmv has quit [Ping timeout: 260 seconds]
<ifreund> zags: swap remove while iterating is well defined
<ifreund> it of course means that you may not see all the items
riba has quit [Ping timeout: 265 seconds]
dddddd has quit [Ping timeout: 256 seconds]
dddddd has joined #zig
marijnfs has joined #zig
<marijnfs> I have some serialisation code but it ends up in some infinite loop
<marijnfs> Is there something obviously wrong there?
<g-w1> at comptime or runtime?
<marijnfs> the loop is at runtime
<marijnfs> so it compiles fine
<marijnfs> strange thing is debugger doesn't give me some infinite stack or something
<g-w1> i dont see any runtime loops
<ifreund> what is msg