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/
wilsonk has joined #zig
wilsonk is now known as Guest7197
Patrice_ has quit [Read error: Connection reset by peer]
a92 has joined #zig
earnestly has quit [Ping timeout: 272 seconds]
foobles has joined #zig
joaj has quit [Ping timeout: 264 seconds]
joaj has joined #zig
squeek502 has joined #zig
frmdstryr has joined #zig
squeek502 has quit [Remote host closed the connection]
joaj has quit [Ping timeout: 264 seconds]
foobles has quit [Remote host closed the connection]
a92 has quit [Quit: My presence will now cease]
earnestly has joined #zig
crimson_penguin has quit [Ping timeout: 256 seconds]
dom96 has quit [Ping timeout: 256 seconds]
foobles has joined #zig
crimson_penguin has joined #zig
dom96 has joined #zig
dom96 has quit [Changing host]
dom96 has joined #zig
CodeSpelunker has joined #zig
frmdstryr has quit [Ping timeout: 256 seconds]
kristoff_it1 has quit [Ping timeout: 258 seconds]
stripedpajamas has joined #zig
foobles has quit [Remote host closed the connection]
kristoff_it1 has joined #zig
ur5us has quit [Ping timeout: 264 seconds]
CodeSpelunker has quit [Quit: CodeSpelunker]
GrooveStomp has joined #zig
kristoff_it1 has quit [Ping timeout: 260 seconds]
osa1 has joined #zig
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
wilsonk_ has joined #zig
Guest7197 has quit [Ping timeout: 240 seconds]
a_chou has joined #zig
zippoh` has joined #zig
zippoh has quit [Ping timeout: 240 seconds]
x2C25 has quit [Ping timeout: 260 seconds]
a_chou has quit [Quit: a_chou]
LanceThePants has quit [Read error: Connection reset by peer]
LanceThePants has joined #zig
stripedpajamas has quit [Quit: sleeping...]
earnestly has quit [Ping timeout: 264 seconds]
wilsonk_ has quit [Quit: Leaving]
dbandstra has joined #zig
wilsonk has joined #zig
wilsonk is now known as Guest78336
waleee-cl has quit [Quit: Connection closed for inactivity]
x2C25 has joined #zig
dbandstra has quit [Quit: leaving]
PC980177 has quit [Ping timeout: 260 seconds]
Biolunar has quit [Ping timeout: 246 seconds]
Biolunar has joined #zig
tane has joined #zig
squeek502 has joined #zig
skuzzymiglet has joined #zig
cole-h has quit [Ping timeout: 265 seconds]
zippoh` has quit [Ping timeout: 256 seconds]
deltamaniac[m] has quit [Quit: Idle for 30+ days]
<alexnask[m]> PSA for zls semantic token users: union, struct, enum, opaque, namespace are no longer token types in master.
<alexnask[m]> (so for example in vscode settings changing "struct" : "<color>" to "type.struct" : "<color>" will yield the same as before)
<alexnask[m]> Instead, type is used for all but they have been added to token modifiers
supercoven has joined #zig
Stephie has quit [Quit: Fuck this shit, I'm out!]
Stephie has joined #zig
PC980177 has joined #zig
PC980177 has quit [Client Quit]
PC980177 has joined #zig
riba has joined #zig
ur5us has joined #zig
riba has quit [Ping timeout: 260 seconds]
ur5us has quit [Ping timeout: 264 seconds]
x2C25 has quit [Ping timeout: 256 seconds]
marnix has quit [Ping timeout: 240 seconds]
marnix has joined #zig
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
earnestly has joined #zig
skuzzymiglet has quit [Read error: Connection reset by peer]
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
omglasers2 has joined #zig
drazan has quit [Ping timeout: 240 seconds]
drazan has joined #zig
joaj has joined #zig
marnix has quit [Remote host closed the connection]
marnix has joined #zig
<dominikh> is there a shorthand for initializing a variable to all zeroes? for example in `var m: [9]f32`, without having to specify 9 zeroes.
<ifreund> var m = [1]f32{0} ** 9;
<dominikh> how about a struct with numerous fields that I all want to be zero?
<ifreund> there's std.mem.zeros() but see the doc comment
<ifreund> zero-initing a struct usually isn't very idiomatic zig
<g-w1> you could set default values for the struct in the definition and then do .{}
<dominikh> ifreund: why is that?
<alexnask[m]> also std.mem.zeroInit that will zero out the fields if they have no default value or set them to the default value otherwise (this is super useful for WINAPI structs that are zero inited and contain a sizeof field)
<ifreund> dominikh: the idea is that variables should always be in a valid state if initialized or `undefined` if not. Zero initializing every field in a blanket way might result in nonsensical values in some cases
<ifreund> as always though, it depends
joaj has quit [Ping timeout: 244 seconds]
<dominikh> well, sure. probably shouldn't zero initialize a pointer that can't be zero. but there is a lot of data where all zeroes does make sense
joaj has joined #zig
<ifreund> default values for your fields may make more sense as well
<dominikh> possibly, yeah. I haven't gotten the hang of when to specify default values yet
<ifreund> I've been using them more and more recently, pretty much whenever the intial value I want is comptime known and always the same
<dominikh> now if only array types could have default values, too.
<dominikh> (transform matrix as a [9]f32, would've been handy to have the identity matrix as the default; but of course I could just have a constant Identity instead)
<alexnask[m]> wdym? you can use array literals to set array's default values
<ifreund> yeah there's nothing stopping you from setting the identity matrix as the default value
<dominikh> `const Matrix = [9]f32;` – I don't think I can provide a default value for this type?
<dominikh> so that `var m: Matrix = .{}` is the identity matrix
<ifreund> ah yeah, that's not a struct so no default values
<dominikh> right
<ifreund> could do this ofc: const Matrix = struct { data: [9]f32 = [9]f32{1,0,0,0,1,0,0,0,1} };
<dominikh> I think I'd rather go with `const Identity = Matrix{1,0,...}` – don't want to indirect all accesses through a field.
<ifreund> I agree
kristoff_it1 has joined #zig
<dominikh> ah, no methods on types other than structs, either. I have much to unlearn :)
<ifreund> that's something I wouldn't mind seeing tbh, though I'm not sure how it would work
frmdstryr has joined #zig
<ifreund> probably ties into the distinct types proposal
<g-w1> what is the distinct types proposal?
<dominikh> ifreund: you could convince people to like UFCS ;) but I'd rather not see that.
<g-w1> thanks
<dominikh> oh yeah, definitely want distinct types, too.
<dominikh> --verbose-llvm-ir prints the LLVM IR before any LLVM optimizations ran, right?
<dominikh> and if so, is there a way to dump the optimized IR?
marnix has quit [Ping timeout: 256 seconds]
marnix has joined #zig
<alexnask[m]> Yes, the emitted IR is unoptimized. I dont believe there is a way to print the IR after the optimization passes currently though it would be quite a cool feature
<scientes> alexnask[m], --emit-ir
<scientes> --release-fast --emit=llvmir
<scientes> I think will do it
marnix has quit [Ping timeout: 272 seconds]
<scientes> --emit-ir is clang
<scientes> dominikh, ^ but you should add your own zig_panic function if you want to reduce the amount of emitted ir
* dominikh nods
<dominikh> thank you
<alexnask[m]> Ah, didnt realize emit-lvvm-ir was after the optimizations, cool
<scientes> you can also run the unoptimized ir through llvm's opt tool
<scientes> as llvm's internal tests do
<dominikh> hm, what command is --emit=llvmir an argument to? I don't see it in zig build-obj's help output – or are you suggesting to run zig's --verbose-llvm-ir output through llc?
<g-w1> i think just run it through opt
<alexnask[m]> femit-llvm-ir[=path] Produce a .ll file with LLVM IR (requires LLVM extensions)
marnix has joined #zig
mmohammadi9812 has quit [Ping timeout: 240 seconds]
mmohammadi9812 has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
Kingsquee has quit []
drazan has quit [Ping timeout: 256 seconds]
gunnara has joined #zig
drazan has joined #zig
radgeRayden has joined #zig
lucid_0x80 has joined #zig
mmohammadi9812 has quit [Ping timeout: 246 seconds]
mmohammadi9812 has joined #zig
skuzzymiglet has joined #zig
mmohammadi9812 has quit [Ping timeout: 240 seconds]
donniewest has joined #zig
gunnara has quit [Ping timeout: 245 seconds]
dumenci has joined #zig
mmohammadi9812 has joined #zig
lucid_0x80 has quit [Ping timeout: 256 seconds]
lucid_0x80 has joined #zig
dumenci has quit [Ping timeout: 260 seconds]
<betawaffle> does zig already make use of io_uring?
waleee-cl has joined #zig
joaj has quit [Ping timeout: 272 seconds]
joaj has joined #zig
lucid_0x80 has quit [Ping timeout: 258 seconds]
skuzzymiglet has quit [Ping timeout: 260 seconds]
lucid_0x80 has joined #zig
joaj has quit [Remote host closed the connection]
joaj has joined #zig
haliucinas has quit [Remote host closed the connection]
haliucinas has joined #zig
cole-h has joined #zig
Xavi92 has joined #zig
hnOsmium0001 has joined #zig
skuzzymiglet has joined #zig
CodeSpelunker has joined #zig
donniewest has quit [Read error: Connection reset by peer]
donniewest has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
joaj has quit [Ping timeout: 272 seconds]
lucid_0x80 is now known as suskun
tane has quit [Quit: Leaving]
radgeRayden_ has joined #zig
radgeRayden has quit [Ping timeout: 272 seconds]
<dominikh> http://sprunge.us/9FSmhg – am I being utterly stupid today? why isn't it executing the outer while more than once?
<ifreund> dominikh: you don't reset j to 0
<ifreund> it is executing the outer while 3 times
Akuli has joined #zig
<dominikh> oh my god
<dominikh> so that's a yes on being utterly stupid
<dominikh> thanks
<ifreund> no problem, we've all been there :P
<dominikh> on that note, is there something more akin to C-style for loops, being able to declare the loop counter in the scope of the loop?
<ifreund> nope
<ifreund> you can wrap both the declaration and the loop in a block though if you like
<dominikh> yay, more nesting :/
<dominikh> is there a design rationale behind this omission?
<g-w1> I was confused why you are allowed to declare variables in loops? since there is no shadowing allwed, shouldn't this not be allowed: `for (thing) |thing2| {const v = 10;}`?
<g-w1> is it because v is always of same type?
<g-w1> or because v goes out of scope at end of iteration?
<ifreund> the latter
<ifreund> dominikh: here's the issue: https://github.com/ziglang/zig/issues/5070
<dominikh> þanks!
<dominikh> thanks, even
<ifreund> to be honest I didn't like it at first but I've grown indifferent
<ifreund> I think having the variable declarations separate is more readable but I don't like polluting the scope
<dominikh> yeah, especially with the "no shadowing" rule
<ifreund> some C coding styles prohibit using the first part of the for loop btw
<dominikh> if we're going to argue with C style guides, we can just pull up MISRA and forbid most things :P
<ifreund> heh
CodeSpelunker has quit [Remote host closed the connection]
CodeSpelunker has joined #zig
frmdstryr has quit [Ping timeout: 272 seconds]
frmdstryr has joined #zig
skuzzymiglet has quit [Ping timeout: 260 seconds]
x2C25 has joined #zig
Kena has joined #zig
CodeSpelunker has quit [Ping timeout: 265 seconds]
<Kena> Hello computational people. Is the notation `error.OutOfMemory` (like ziglang.org) is preferred over `error{OutOfMemory}` (like ziglearn.org) ? The stayling guide denotes that a type must be written in PascalCase (TitleCase to be precise) but do not go into details regarding to the error union set type.
<fengb> The former is an actual error while the latter is an error union. They do different things
<g-w1> I think error.OutOfMemory is for one error but error{OutOfMemory} is an errorset
<fengb> Error unions are types but the actual error is a value to be returned
<g-w1> >the latter is an error union. is it a set?
<fengb> Sorry, yes error set
<Kena> I'm sorry guys, I didn't know.
<fengb> Error union is the set + the value returned e.g. error{Foo}!ValueType
<fengb> Left is the error set, right is the value type, both together is the union
CodeSpelunker has joined #zig
skuzzymiglet has joined #zig
<Kena> Yes I understand the binary operator ! and its ramifications. So error{OutOfMemory} is just a value of an error set, not a union error type right?
<fengb> It’s an error set declaration
<g-w1> you would use error.OutOfMemory when doing catch |e| if (e == error.OutOfMemory)
<g-w1> or switch (e) { error.OutOfMemory =>
<Kena> Then it is different than error.OutOfMemory because error{OutOfMemory} can't be accessed before being declared, I am correct?
<fengb> @TypeOf(error.OutOfMemory) == error{OutOfMemory}
<fengb> You can think of it sorta like that
<alexnask[m]> error.Foo is equivalent to error{Foo}.Foo
<g-w1> does Dir.readLink give the absolute path, or just the relative path in relation to dir of the path to where the link leads?
<Kena> But I didn't see error{OutOfMemory}.OutOfMemory once :/
<alexnask[m]> Yes, because the shorthand error.OutOfMemory is way more convenient ;)
Kena has quit [Remote host closed the connection]
<alexnask[m]> error.OutOfMemory <- error value, error{OutOfMemory} <- error set (which is a type)
xackus has joined #zig
<g-w1> i think my problem is related to how symlinks on linux works. will it return relative or absolute?
Kena has joined #zig
<g-w1> kena: I think you missed an answer to the question: error.OutOfMemory <- error value, error{OutOfMemory} <- error set (which is a type)
<Kena> Thanks a lot fengb gw-1 and alexnask[m] for these explanations
<Kena> Yes, the web IRC client has been disconnected for a unknown reason.
skuzzymiglet has quit [Ping timeout: 260 seconds]
<Kena> But the log https://freenode.irclog.whitequark.org/zig/2020-11-06 told me about it :)
ur5us has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
<dutchie> https://0x0.st/idR5.txt # is this (eventual) FileNotFound error expected when running the std tests?
<dutchie> i'm on nixos
osa1 has quit [Ping timeout: 246 seconds]
suskun has quit [Ping timeout: 256 seconds]
a92 has joined #zig
<g-w1> when trying to repro this, zig build test-std just loops forever, testing the stdlib over and over agin
<g-w1> *again. is this happening for anyone else
brentp has joined #zig
<brentp> can anyone suggest a way to get around this: https://github.com/ziglang/zig/issues/6987 ?
<Kena> zig build test-stdCannot run step 'test-std' because it does not exist
<g-w1> kena: are you in the zig source repo?
<Kena> No... You mean I have to clone the repository ?
<g-w1> if you want to test the zig standard library, you have to have a copy of it
<Kena> Allright, I'm downloading Git
a92 has quit [Quit: My presence will now cease]
dch has quit []
dch has joined #zig
<Kena> Do I have to create a custom build.zig file?
cole-h has quit [Ping timeout: 240 seconds]
omglasers2 has quit [Read error: Connection reset by peer]
<g-w1> no
<Kena> Semantic analysis is in progress, mon intel I3 is almost on its knees
omglasers2 has joined #zig
<alexnask[m]> I would suggest running the tests with -Dskip-release -Dskip-non-native
supercoven has quit [Ping timeout: 260 seconds]
<Kena> What's the meaning of the first flag please?
<g-w1> it will only compile it in debug mode so much faster compile times, but less fast runtime. the test run fast though.
<dominikh> is there a function that sets fields to their default values? e.g. so I can use it after allocating memory
<g-w1> does thing.* = .{}; not work?
<dominikh> good point
<dominikh> well, not quite the same, if not all fields have defaults
<g-w1> you could program one at comptime using std.builtin.TypeInfo.Struct.fields[*].default_value so you can just loop over this
<g-w1> const ti = @TypeInfo(@TypeOf(struct_passed)); const sf = switch (ti) {.Struct |s| => s, else => unreachable,}; for (sf.fields) |field| { set struct_passed.field to field.default_value; }
<g-w1> this is how I would do it
<dominikh> makes sense
elbow-jason has quit [Remote host closed the connection]
<Kena> Does the LLVM emit output phase related to the run-time part of things?
<Kena> Or is it still compilation-time work?
<Kena> Allright, so my dear dutchie. My zig version is: `0.6.0+c9551652b`, my OS is: `x86_64-windows.win10_19h1` and the output of `zig buil test-std -Dskip-release -Dskip-non-native` is available here: https://zero.hurtig.ninja/?30ed85ebb3a3f4da#UFz1UOvM3zzwFQWcM1SxlnKOR4wRD1kG6T8W83TBg2o=
<g-w1> Kena: llvm is what generates the final machine code/optimising it. it is not part of zig, so it is just generating machine code, not compile time evaluating stuff.
<Kena> However, for a side note it is `zig targets` that produces an infinite loop...
<Kena> Thank you g-w1, I'll note it in a memorandum.
<g-w1> can you try zig targets in your home directory?
Cynthia has quit []
<Kena> I failed a migration from debian stable to voidlinux and lost my entire RAID1, i'm just babbling on a windows 10 laptop for several months. Where is a home direction on windows?
Cynthia has joined #zig
<g-w1> C:\
<Kena> Same here, `zig targets` overhelms the terminal with the same looped JSON data
<g-w1> interesting. i would say report a bug on github issues. i dont think it is reported.
drazan has quit [Remote host closed the connection]
drazan has joined #zig
<Kena> My bad, it's not a infinite loop but it produces such noise that the output produces overwhelm the scrolling capacity of the powershell. Printing targets have a different behaviour than the one produced on UNIX-based operating systems.
<Kena> In fact, I don't think it narrows down the actual architecture target but rather prints the entire JSON possible values...
<Kena> Which it would be a bug-label issue if someone can confirm my saying on windows 10.
<pixelherodev> It's supposed to print all possible targets, I think
wootehfoot has joined #zig
<pixelherodev> The fact that Windows' terminals can't handle it isn't a bug with Zig ;)
<travv0> my windows spits it out in a fraction of a second lol
<Kena> Here is a sample printed by the limited capacity of the Windows' terminal. Please tell me if it the intended behaviour of `zig targets`: https://zero.hurtig.ninja/?edb19debdfa6353f#zJps8all0i96dY6f4HACxBB9xD6qa9yQeoPSdibNgNY=
<travv0> yep that looks right
<alexnask[m]> yes, this looks ok, it just outputs a huge json object
<Kena> Allright sorry for the spam.
<pixelherodev> travv0: "some of Windows' terminals" :P
<alexnask[m]> you should pipe it into a file or some utility like jq to browse it
<Kena> Agreed.
<pixelherodev> Yeah, it's not meant for human consumption
<pixelherodev> An alternate form of output which *is* a bit more edible would bv neat
<pixelherodev> s/bv/be
<Kena> with a new flag like zig targets --current
<Kena> or -Dskip-non-native like for zig build to preserve the symmetry of flags' syntax
<Kena> s/for/with
joaj has joined #zig
<travv0> yeah i'd like a human-readable version too, i definitely was surprised by the output the first time i ran `zig targets`
<Kena> or zig targets -Dskip-old to output only the last decade architectures lol
<travv0> lo
<travv0> *lol
<Kena> bye bye armv4...arm7
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
<earnestly> Does Windows have jq?
frmdstryr has quit [Ping timeout: 272 seconds]
<earnestly> 12,000 lines of output, heh. Easily filtered with jq, but that is impressive
<earnestly> zig targets | jq .native
<earnestly> triple looks odd: "triple": "x86_64-linux.5.9...5.9-gnu.2.32"
<travv0> yeah my triple looks look that as well
<Kena> "triple": "x86_64-windows.win10_19h1...win10_19h1-msvc",
<Kena> It look likes it exposes the same clustering of data than linux-kernel min.max version (I don't recall the exact nomenclature,)
<Kena> min and max were always assigned the same values within a max.min.patch json array
wootehfoot has quit [Ping timeout: 260 seconds]
ur5us has quit [Ping timeout: 264 seconds]
marnix has quit [Ping timeout: 272 seconds]
ky0ko has quit [Remote host closed the connection]
ky0ko has joined #zig
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
marnix has quit [Ping timeout: 260 seconds]
novaskell has joined #zig
kristoff_it2 has joined #zig
kristoff_it1 has quit [Ping timeout: 246 seconds]
<andrewrk> when you compile for the native target, the min == max
<andrewrk> that way the std lib does not include any bloat for older kernel versions or newer kernel versions - only exactly the correct code for the native one
Akuli has quit [Quit: Leaving]
wootehfoot has joined #zig
<Kena> Thanks. On another note, does the 0.8.1 branch implies that the 0.9.0 has a such broad functional scope which require a intermediate-step to be migrated to?
wootehfoot has quit [Read error: Connection reset by peer]