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/
ur5us__ has joined #zig
a92 has joined #zig
<dominikh> does Zig have a native way of doing this? https://play.golang.org/p/uzOImGWzC8L
<g-w1> You mean calling a func without parens?
<dominikh> g-w1: I mean passing a bound function as a function
<g-w1> oh yeah i misread
<fengb> Nope, no closure support
<dominikh> alright, thanks
copy has quit [Quit: No Ping reply in 180 seconds.]
copy has joined #zig
decentpenguin has quit [Read error: Connection reset by peer]
waleee-cl has quit [Quit: Connection closed for inactivity]
<g-w1> does anyone know why this project is closed? https://github.com/ziglang/zig/projects/2
squeek502 has quit [Remote host closed the connection]
a92 has quit [Quit: Leaving]
earnestly has quit [Ping timeout: 240 seconds]
CmdrCrisp has quit [Ping timeout: 264 seconds]
jzelinskie has quit [Ping timeout: 260 seconds]
utzig has quit [Read error: Connection reset by peer]
eddyb[legacy] has quit [Ping timeout: 246 seconds]
ovf has quit [Ping timeout: 260 seconds]
hnOsmium0001 has quit [Read error: Connection reset by peer]
eddyb[legacy] has joined #zig
utzig has joined #zig
hnOsmium0001 has joined #zig
jzelinskie has joined #zig
ovf has joined #zig
frmdstryr has quit [Ping timeout: 260 seconds]
<wilsonk_> g-w1, I think that was merged into the main repo? Andrew had mentioned that it would be merged once it was at a certain point...maybe during the big stage2 upgrade?
benjamin-l has quit [Ping timeout: 264 seconds]
<g-w1> probably. so I should just look for the stage2 tags now on issues to find a good one?
<wilsonk_> I think so, yes
<daurnimator> Ristovski: capnproto is designed to not be parsed/serialized; but be used as-is in memory
<daurnimator> for good capnproto support we need https://github.com/ziglang/zig/issues/6478
<companion_cube> capnproto is based on codegen, isn't it?
<companion_cube> so you could have a []u8 and read from there
<daurnimator> companion_cube: the usual way to implement capnproto is to run codegen that generates all your struct definitions; with getters and setters
<companion_cube> yeah
<daurnimator> with #6478 we wouldn't need the getters and setters
<companion_cube> you only need byte-addressability I think
<companion_cube> I can't imagine the capnproto guy packed stuff more tightly than byte level
waleee-cl has joined #zig
<daurnimator> companion_cube: correct I think. but you need e.g. union members that aren't all together
<daurnimator> I suppose you might still need getters/setters for endianess
<companion_cube> it's probably simpler to go via []u8 anyway
<companion_cube> but we'll see :)
<companion_cube> (same goes for flatbuffers I imagine, never looked into that one)
<pjz> with zig that compilation can be in the zig code instead of an external tool
<companion_cube> if you implement the whole parser+compiler of capnproto schemas in zig, sure
<g-w1> I think dirname strikes again, but in a weird way: I am getting the infinite zig build but in a directory with build.zig, it cannot find the standard library because I moved the binary relative to the stdlib. This was very confusing to me when I first saw it, I dont know if this is a priority before 0.7.0, but here it is https://i.imgur.com/sOMWJIW.png. I am building a standard library for another thing not zig,
<g-w1> but it cant find zig standard lib i think
<g-w1> I downloaded the zig to ~/.local/bin/zig-asdfanfua/zig but then moved it to ~/.local/bin/zig. I think it should tell you if it cant find the stdlib instead of doing this.
<g-w1> this is on the latest linux tarball downloaded from ziglang.org
<g-w1> #6872
ur5us__ has quit [Ping timeout: 264 seconds]
ur5us__ has joined #zig
x2C25 has quit [Ping timeout: 264 seconds]
earnestly has joined #zig
ur5us__ has quit [Ping timeout: 264 seconds]
x2C25 has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
kristoff_it1 has quit [Ping timeout: 240 seconds]
cole-h has quit [Ping timeout: 265 seconds]
osa1 has joined #zig
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
riba has joined #zig
squeek502 has joined #zig
osa1 has quit [Quit: osa1]
_whitelogger has joined #zig
x2C25 has quit [Ping timeout: 240 seconds]
xackus has joined #zig
geert_ has joined #zig
x2C25 has joined #zig
osa1 has joined #zig
jjsullivan has quit [Ping timeout: 264 seconds]
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
osa1 has quit [Remote host closed the connection]
marnix has quit [Remote host closed the connection]
marnix has joined #zig
nycex has quit [Ping timeout: 240 seconds]
nycex has joined #zig
riba has quit [Ping timeout: 268 seconds]
Kingsquee has quit []
Kena has joined #zig
<Kena> Hello electric pulses computing people. In the documentation, at Type coercion Arrays and pointers, there is the following snippet: // Single-item pointers to arrays can be coerced to// unknown length pointers.test "*[N]T to [*]T" { var buf: [5]u8 = "hello".*; const x: [*]u8 = &buf; expect(x[4] == 'o'); // x[5] would be an uncaught out
<Kena> of bounds pointer dereference!
<Kena> Yet `expect(x[5] == 0);` compiled just fine. Is it unexpected or does it mean an unknown-length pointer was implicitly casted into a sentinel-value pointer?
<daurnimator> Kena: `[*]` have no bounds checking. indexing past the end of the array is you *knowing* that its valid to do so.
<Ristovski> daurnimator: re: capnproto: Yes, capnproto also has the added benefits of being able to mmap large, raw messages on disk
<Kena> Allright, thanks daurnimator.
<Ristovski> hmm, I wonder, bare structs are pretty easy to to serialize with std.io.serializer, custom types just need a serialize/deserialize implementation, but how would one handle generic types like a List for example?
<Ristovski> Or for example, to serialize std.ArrayList
gazler has quit [Remote host closed the connection]
_whitelogger has joined #zig
skuzzymiglet has joined #zig
Kena has quit [Remote host closed the connection]
frett27 has joined #zig
marnix has quit [Ping timeout: 264 seconds]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
waffle_ethics has joined #zig
frmdstryr has joined #zig
skuzzymiglet has quit [Ping timeout: 240 seconds]
geert_ has quit [Ping timeout: 258 seconds]
x2C25 has quit [Ping timeout: 264 seconds]
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
LanceThePants has quit [Read error: Connection reset by peer]
sawzall has joined #zig
frett27 has quit [Ping timeout: 260 seconds]
waffle_ethics has quit [Ping timeout: 268 seconds]
waffle_ethics has joined #zig
mmohammadi9812 has quit [Quit: Quit]
donniewest has joined #zig
geert_ has joined #zig
mmohammadi9812 has joined #zig
tane has joined #zig
mmohammadi9812 has quit [Ping timeout: 272 seconds]
waffle_ethics has quit [Ping timeout: 265 seconds]
radgeRayden has quit [Ping timeout: 272 seconds]
radgeRayden_ has joined #zig
radgeRayden_ is now known as radgeRayden
waffle_ethics has joined #zig
endragor has joined #zig
mmohammadi9812 has joined #zig
zyancey has joined #zig
zyancey has quit [Remote host closed the connection]
Akuli has joined #zig
waleee-cl has joined #zig
waffle_ethics has quit [Ping timeout: 240 seconds]
tane has quit [Quit: Leaving]
cole-h has joined #zig
waffle_ethics has joined #zig
skuzzymiglet has joined #zig
x2C25 has joined #zig
frett27 has joined #zig
hnOsmium0001 has joined #zig
tane has joined #zig
<frmdstryr> Is there a way to make print format int struct field values in hex? Similar to how `p/x *some.struct` does with gdb?
<Nypsie[m]> `print("{x}", .{some_int_value})`
lucid_0x80 has joined #zig
<Nypsie[m]> Aaaah wait, for a struct field
<Nypsie[m]> You'll have to write a format() function on the struct
<frmdstryr> Hmm actually that does seem to work, for some reason I thought that gave an error before.
<Nypsie[m]> Great!
<frmdstryr> Thanks!
jayschwa has joined #zig
dumenci has joined #zig
geert_ has quit [Remote host closed the connection]
lucid_0x80 has quit [Ping timeout: 256 seconds]
frett27 has quit [Ping timeout: 264 seconds]
frett27 has joined #zig
<andrewrk> wow amazing, I woke up to green CI
<andrewrk> it's like christmas
<travv0> \o/
<companion_cube> christmas would be green *and* red
<bfredl> 31 oct = 25 dec
<bfredl> BECAUSE SCIENCE
<companion_cube> 30 oct, no?
<Nypsie[m]> Timezones ;)
<bfredl> well 30 oct = 24 dec, julafton here in sweden : D
CmdrCrisp has joined #zig
CmdrCrisp has quit [Ping timeout: 264 seconds]
wootehfoot has joined #zig
<andrewrk> OK this list of issues in the 0.7.0 milestone is now an accurate list of what I want to try to get done by the release
decentpenguin has joined #zig
<Nypsie[m]> Great work Andrew, looking forward to it
<ifreund> if you decide to go for #1097 just before a release is definetly better than just after
decentpenguin has quit [Ping timeout: 272 seconds]
<ifreund> (IMO the change makes sense and that camelCase is a local maximum, but that will cause a LOT of churn)
<betawaffle> std is expected to change (possibly significantly) before a 1.0 release, right?
<ifreund> yes, though it's generally better to break things earlier rather than later if you know they need to be broken at some point before 1.0
<jayschwa> I have 2 of 3 steps awaiting PR review on https://github.com/ziglang/zig/issues/6466. The last step is dependent on the first 2.
<g-w1> out of curiosity why is snake_case better?
<g-w1> this makes sense
<ifreund> andrewrk: Is moving the std to snake_case enum/union fields per #2101 something you want to happen before 0.7.0 is released? if so I could probably flex some text editor muscles this weekend
<ifreund> (Looking for something I can take off your plate)
<andrewrk> ifreund, oh I just meant to make a decision on the proposal
<andrewrk> good to know you're up for that though :)
<ifreund> well #2101 is already accepted :P
a92 has joined #zig
<andrewrk> oops, got that one mixed up with the other one! it's moved to 0.8.0 now. I'm too afraid of regressing something because of lazy analysis to do 2101 right now
<betawaffle> i have to say, XML_HTTP_Request is ugly, but it's better than XmlHttpRequest
<ifreund> makes sense
Kena has joined #zig
wootehfoot has quit [Read error: Connection reset by peer]
dumenci has quit [Ping timeout: 246 seconds]
<betawaffle> is there going to be a Solution™ to lazy analysis in the future?
decentpenguin has joined #zig
<g-w1> when writing a library, are the public functions not analyzed?
<andrewrk> betawaffle, closest idea is: https://github.com/ziglang/zig/issues/3028 but it's probably unrealistically difficult to implement
<andrewrk> I think we might just be stuck with it as a pro/con of the language
<betawaffle> interesting.
osa1 has joined #zig
<betawaffle> isn't this something that some sort of code coverage report can help with?
<betawaffle> like, as long as *something* is exercising a line of code, we're probably good
<Kena> I have a noobie question, in the documentation, there is the following snippet: test "ignoring expression value" { foo();}fn foo() i32 { return 1234;}
<Kena> Please, why the expression value is ignored? I do not understand the reasoning behind this.
<a92> You just call the function foo and do nothing with it
<a92> There's no reason it would be used; so it is considered to be ignored
<Kena> Allright, I think I understand, thank you.
<a92> Is it too OO/bad practice/against the zen to have a single-field struct and define methods/functions associated with it instead of just defining "free-floating" functions with the struct's field type as a parameter?
<ifreund> nah
<ifreund> OO is bad because of stuff like inheritance causing implicit things to happen
<earnestly> Depends on the language; the former can produce horrific code explosion
<a92> What channel are we in, earnestly?
<earnestly> I don't know how zig generates code in this case
<betawaffle> we're in #zig
LanceThePants has joined #zig
<ifreund> shouldn't make a difference afaik
<earnestly> ifreund: (It's the main reason rust compiles so slowly, according to thestinger)
<earnestly> Because it doesn't use free functions
sawzall has quit [Ping timeout: 268 seconds]
<earnestly> But this was many years ago
<earnestly> "Boost on steroids"
<ifreund> how does that relate to code explosion though?
<companion_cube> earnestly: rust has free functions
<earnestly> ifreund: I don't think it does in Rust's case
<companion_cube> it's slow mostly because it creates a ton of LLVM IR
<earnestly> companion_cube: The std back then was basically boost
marnix has quit [Read error: Connection reset by peer]
<companion_cube> maybe, but these days rust is not close to boost; it doesn't even have headers
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
<companion_cube> (that being said, monorphization is costly in rust too, and it'll be in zig too if people are not careful)
marnix has joined #zig
<earnestly> (I don't think the use of "headers" is relevant in terms of library design)
<ifreund> yeah, that's totally orthagonal
<companion_cube> putting templates in headers is not orthogonal
<companion_cube> it means you have to recompile the whole thing at every call site
<companion_cube> if you have things like modules+concepts (C++ names) or modules+traits (rust), you can typecheck the template only once, produce some IR, and then use that IR at each callsite
<companion_cube> (still have to do some type-specific optimizations at each call site but that's unavoidable)
osa1 has quit [Ping timeout: 260 seconds]
<Kena> Please, what is monorphization in a few words? I too would like to avoid some bad practices.
layneson has joined #zig
<betawaffle> creating unique implementations of a generic thing, iirc
skuzzymiglet has quit [Ping timeout: 256 seconds]
<companion_cube> it's just that when you parametrized code by some types (like ArrayList), and then you use it with a bunch of different types, the code is duplicated for each concrete type
waffle_ethics has quit [Ping timeout: 268 seconds]
<companion_cube> so typically in rust or C++, the code of `vector`/`Vec` is duplicated for a large number of types, since it's such a pervasives container
<betawaffle> it doesn't necessarily cost more than the equivalent _literally duplicated_ code, like you'd have to do in Go, for example
<companion_cube> no, clearly not, especially if you can duplicate it per function (instead of the whole module)
<companion_cube> but it's why some C++ binaries are super big
<betawaffle> yep, which you can't do in Go
<companion_cube> yeah of course
<companion_cube> just not having generics is a super bad solution
<betawaffle> i write go for $dayjob, and i agree
a92 has quit [Quit: Leaving]
<betawaffle> that's why i'm waiting for the day when zig can do everything i would otherwise do in go
<Kena> Thank you both.
<ifreund> hmm, will I suffer any kind of ill effects from telling zig to link to a library that I don't actually use?
<ifreund> I don't know enough about how elf files work
wootehfoot has joined #zig
xmn11 has joined #zig
<ifreund> yeah that seems like something I want to avoid
<earnestly> betawaffle: Be avant garde and use ada instead
<earnestly> (instead of go)
jaredmm has quit [Read error: Connection reset by peer]
jaredmm_ has joined #zig
<earnestly> You get your algol, with manually instantiated generics :p
<betawaffle> heh, i ain't got time for that
<ifreund> I feel like ada is pretty close to the polar opposite of go
<earnestly> ifreund: They both come from the school of algol/pascal. Go is almost identical, even in syntax, to algol
<companion_cube> as in, it's carefully designed?
<earnestly> ifreund: As for Ada, that also comes from algol/pascal but with a very rigorous design document (steelman) which in many cases was not possible to fulfil 35 years ago lol
<earnestly> But the scope is different, for sure. Ada is more for embedded realtime systems and so many of the conveniences aren't available
<ifreund> yeah, they are in the same language family syntax-wise but they have very different feature sets and use-cases
<earnestly> (Like a GC)
<companion_cube> doesn't ada have generics though?
<earnestly> Although apparently, so I'm told, the ada spec doesn't rule out the ability for it to be implemented with a GC
<ifreund> ada has everything
<earnestly> companion_cube: Yeah, it does generics. It has 'class' objects, but they're closer to typeclasses than structs
<companion_cube> can ada run on the jvm, in theory? :)
<earnestly> companion_cube: It has native FFI to java :p
<earnestly> (and fortran)
<companion_cube> via JNI?
<earnestly> I'm not sure how it's implemented
<companion_cube> interesting, in any case
<earnestly> The one nice thing about Ada, which I'd love all languages to do, is a) Have an ISO standard that is *freely available* and it also compiles with a compiler conformance test suite
<earnestly> The b was the test suite, but b got lost
<earnestly> compiles/comes ...
<earnestly> When was the last time a language standard came with a comformance test suite?
<earnestly> So you can ensure that your compiler follows it
<ifreund> we should do that for zig
<earnestly> ifreund: This is a bit old but may be an interesting skim: https://dwheeler.com/steelman/steeltab.htm
<companion_cube> hu, David Wheeler is interested in Ada?
<companion_cube> (or, was)
<earnestly> Yeah, very much so
<ifreund> we already have a test suite for the compiler, it would just need to be made easy for other implementations to use as well
<companion_cube> earnestly: you know him?
<earnestly> ifreund: grep for appendix
<earnestly> companion_cube: No no, just read stuff he has written
<companion_cube> ah, yeah, cool
<companion_cube> he's also involved with metamath (?!)
<earnestly> He tried to make Ada a thing in FOSS circles
<ifreund> earnestly: the appendix makes me think he has different priorities than I do :D
<earnestly> ifreund: The table? That table contains the steelman requirements
<companion_cube> it'd be interesting to compare rust to Ada following this table, tbh
<ifreund> yeah the table
rzezeski has quit [Ping timeout: 260 seconds]
kwilczynski has quit [Ping timeout: 272 seconds]
r0bby has quit [Ping timeout: 240 seconds]
<earnestly> ifreund: (The US gave out documents starting with strawman, tinman, ironman, etc. to teams (red team, green team, etc.) to implement the requirements. The final document was the steelman, which Ada is an implementation of, by Jean Ichbiah)
kwilczynski has joined #zig
r0bby has joined #zig
<ifreund> where do these requirements come from? and why are they all weighted the same in the comparison?
<earnestly> companion_cube: Heh, "steel"man and rust
marnix has quit [Ping timeout: 264 seconds]
procnto has quit [Ping timeout: 240 seconds]
<earnestly> ifreund: The DOD came up with them
<companion_cube> :D interesting
rzezeski has joined #zig
<earnestly> ifreund: That's quite interesting is that the US DOD required that the implementation be licensed under the GPL
<ifreund> e.g. why is function overloading a requirement with no justification
CodeSpelunker has joined #zig
<ifreund> that is interesting
<earnestly> The document probably expands on these points
procnto has joined #zig
CmdrCrisp has joined #zig
<earnestly> companion_cube: Apparently? http://jedbarber.id.au/steelman.html
<earnestly> ifreund: (Also I do appreciate that Ada's syntax is explicitly designed to a 1-pass parsable, or was initially anyway.)
<ifreund> that is very nice, parsing C++ e.g. is a huge mess
<companion_cube> hmm, 2B is objectionable, rust is also designed to be easy to parse…
<earnestly> Hm, no that wasn't it... the grammar is context-free, iirc
<earnestly> companion_cube: Rust has the << <T> >> problem, no?
<companion_cube> no, not at all
<earnestly> How does it cope with << < T > >>?
<companion_cube> it's always clear whether you're parsing an expression or a type
<earnestly> Hm
<companion_cube> (hence the famous "turbofish" ::<>, which is used to specify a type argument to a function)
<companion_cube> (like f::<i32>())
<companion_cube> it's fugly but relatively rare
<earnestly> They're still getting issues with parsing troubles this month
<companion_cube> that's a bug, not a grammar issue :)
<companion_cube> good one though
<companion_cube> ahah interesting :D
<companion_cube> the perils of tokenizing `>>`
<earnestly> This is the one thing I find endearing about Ada, is that the designers actively try to learn the lessons of the past
<companion_cube> there's the "lexer hack" that exists elsewhere for languages that have a mostly regular grammar, but need a bit of context at the lexer level
<companion_cube> you could have a lexer for types and one for expression, here, and alternate… but it's not worth it
<companion_cube> what's shift right in ada?
<earnestly> shift_right
<companion_cube> ah, good call indeed.
<earnestly> (the syntax is case insentive)
<companion_cube> in OCaml it's `lsr`
<earnestly> lol, or shr
<earnestly> (in others)
<companion_cube> lsl, lsl, asl, lor, land…
<earnestly> There's also shift_right_arithmetic, it can be quite wordy
<earnestly> rotate_right
jjsullivan has joined #zig
donniewest has quit [Quit: WeeChat 2.9]
jaredmm_ has quit [Quit: Bouncin']
jaredmm has joined #zig
CmdrCrisp has quit [Ping timeout: 240 seconds]
jaredmm has quit [Client Quit]
jaredmm has joined #zig
jaredmm has quit [Client Quit]
jaredmm has joined #zig
marnix has joined #zig
layneson has quit [Ping timeout: 264 seconds]
marnix has quit [Ping timeout: 240 seconds]
Kena has quit [Remote host closed the connection]
<Biolunar> There is no way to mark a stack variable as volatile, is there? My use case is a global variable that is modified in a signal handler. In C these variables must be volatile or the read outside of that handler can be optimized out.
<yZ5vlALg86lP> is the maintainer/author of zig-mode in this chan? i have an annoying bug where when i save a zig buffer the cursor jumps to some fixed location in the file
Akuli has quit [Quit: Leaving]
<travv0> is it maybe format on save-related? i disabled that because it was causing lots of problems for me
klltkr has joined #zig
<pjz> where would I look to find info on what @TypeInfo returns for things like functions?
nvmd has quit [Ping timeout: 264 seconds]
nvmd has joined #zig
<ugla> Biolunar: pointers can be marked as volatile, `*volatile T`, https://ziglang.org/documentation/master/#volatile
<Biolunar> ugla: yeah, I saw that. Now I’m questioning whether I need to change globals in signal handlers through volatile pointers or not. If I need the pointer indirection that is quite uncomfortable
nvmd has quit [Ping timeout: 268 seconds]
wootehfoot has quit [Quit: Leaving]
nvmd has joined #zig
<frmdstryr> Biolunar: I think you want to use atomic, not volatile https://ziglang.org/documentation/master/#atomicLoad
frett27 has quit [Ping timeout: 264 seconds]
<yZ5vlALg86lP> travv0: let me try that
<yZ5vlALg86lP> travv0: wow. yeah. that's it.
<travv0> cool
<yZ5vlALg86lP> finally zig-mode is fun again \o/ :)
<travv0> i've been thinking about taking a stab at making the format on save work better but i haven't gotten around to it yet
<travv0> cause it's easy enough to just C-c C-f lol
<Biolunar> frmdstryr: relaxed atomic operations would certainly work, but it feels like overkill for “don’t optimize this read out”.
<yZ5vlALg86lP> even if i do c-c c-f it jumps to this one location
<travv0> well that's weird
nvmd has quit [Ping timeout: 260 seconds]
<frmdstryr> Biolunar: Yeah I agree... if you search for volatile in the issues list there's a few discussions on the topic
<Biolunar> frmdstryr: thx, I’ll have a read for bed time then ;)
commonlylen has joined #zig