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/
<kandinski> waleee-cl: I'm about to download and compile zig from github master, or is there a particualar checkpoint commit that you can recommend?
earnestly has quit [Ping timeout: 265 seconds]
<waleee-cl> kandinski: have you tried the builds from ziglang.org first? They should (probably) work on nixos too
<kandinski> waleee-cl: right, hadn't thought of it at all
<kandinski> so these are daily?
<waleee-cl> last succesful CI-build passing all tests is my understanding
<kandinski> waleee-cl: thanks!
<DonnieWest[m]> Playing around with zig again as a programmer w/ a non-C background. Trying to run `translate-c` on a c file to mess around with stuff and getting `libxml/HTMLTree.h file not found`. Weird thing is that I have `libxml2` installed and present in `/usr/include`. Furthermore, I'm able to compile the project using the included Makefile and gcc
<DonnieWest[m]> I'm figuring this is just something silly I'm missing, so if the answer isn't super obvious I'm happy to include more details, etc
marijnfs has quit [Ping timeout: 256 seconds]
<g-w1> try exe.linkSystemLibrary("libxml2")
<kandinski> DonnieWest: or -llibxml2 if you're running it from the command line
<kandinski> DonnieWest[m]: also, sometimes the library that you link and the one you import are not called the same name
<DonnieWest[m]> `zig translate-c llibxml2 /path/to/file.c` isn't working for me. Hrm.
<DonnieWest[m]> * `zig translate-c -llibxml2 /path/to/file.c` isn't working for me. Hrm.
<DonnieWest[m]> err, `-llibxml2`
<kandinski> for instance, I installed pcre2, but I'm linking to pcre2-8 (for utf8 and ascii), so my command line switch looks like -lpcre-8 and my build line looks like exe.linkSystemLibrary("pcre2-8"), despite the fact that the zig import looks like `@cImport({@cInclude("pcre2.h");});`
<kandinski> DonnieWest[m]: I have a non-C background too, so what I'm sharing is what I learnt literally yesterday. Sorry I can't help you further.
<kandinski> try -lllibxml, without the 2
<kandinski> too many l's though
<DonnieWest[m]> Tried that, didn't work. I did poke around the Makefile though and it looks like they're calling `xml2-config --libs` and it's outputting `-lxml2` among other things
<DonnieWest[m]> Substituting that in the script and it still doesn't work. Weird.
ryuukk__ has joined #zig
ryuukk_ has quit [Read error: Connection reset by peer]
<DonnieWest[m]> `-I/usr/include/libxml2` seems to do the trick though ala that the link shared. More errors but I'm one step closer! Thanks :)
<DonnieWest[m]> Follow up, it's both :P
<DonnieWest[m]> `-I/usr/include/libml2 -lxml2` that worked successfully. Thanks!
a92 has joined #zig
Kingsquee has joined #zig
<kandinski> DonnieWest[m]: this is good to know, and I'm writing this down n my notes
<DonnieWest[m]> Note: It appears I could've reverse engineered this from the Makefile. There's variables called CFLAGS and LDLIBS, which seem to be a sort of C convention. Either way, each of them are calling `xml-config` to grab different bits
<DonnieWest[m]> `xml2-config --cflags` returns the `-I/usr/include/libxml2` bits, `xml2config --libs` returns the `-lxml2` bits
<DonnieWest[m]> s/bits/parts/
<DonnieWest[m]> Turns out, Java/Javascript programmers can learn new tricks :P
msingle has joined #zig
<kandinski> ifreund: it turns out that pcre2 is nice enough to provide a way to pass an allocator explicitly, but I think I'll pass for now.
osa1 has joined #zig
radgeRayden has joined #zig
kristoff_it1 has quit [Ping timeout: 260 seconds]
jmiven has quit [Quit: bye]
jmiven has joined #zig
msingle has quit [Ping timeout: 256 seconds]
<kandinski> can an error have a payload? I'd like to return something like PCRE2CompilationError(<string_with_pcre2_error_message>)
<kandinski> it seems that an error set is an enum, and I want it to be a union
<kandinski> not the Error Union Type, but a Tagged Union
<kandinski> I see it's already a proposal https://github.com/ziglang/zig/issues/2647
a92 has quit [Quit: Leaving]
<ryuukk__> i still wish there was operator overloading
<ryuukk__> but i guess this will do the job, even if i hate having to type .cpy()
<ryuukk__> it's either .cpy or Vec3.zero(), both are ugly, but .cpy is shorter
<ryuukk__> i have the feeling this gonna introduce a bug, forget to call .cpy() for example
<ryuukk__> and tbh i haven't thought about how it's gonna handle cases where i'd do calculations inside parenthesis
<ryuukk__> this will be ugly af
<ryuukk__> this make me sad..
<companion_cube> is `copy` a reserved word?
<ryuukk__> if i start to make methods with different lengths, it's gonna be ugly^2
<ryuukk__> cpy, add, scl, div, sub
<companion_cube> that's the first time I hear this requirement
<companion_cube> what is it useful for?
<ryuukk__> because other languages have operator overloading
<companion_cube> hmm, maybe C++
<ryuukk__> the one that doesnt have, and follow similar naming convention is Java
<ryuukk__> wich nobody uses for math stuff
<g-w1> in haskell, all the operators make it very hard to read imo
<ryuukk__> you can say a + b is hard to read
<ryuukk__> how do matematician read formulaes without operators?
<g-w1> like >>= <=>
<g-w1> that is hard to read
<ryuukk__> cant*
<ryuukk__> they have their meaning
<companion_cube> I don't think you'll change andrew's opinion on hidden control flow
<ryuukk__> .add .scl .sub is even harder to read, AND to write
<g-w1> once you start making ur own meanings, it becomes very hard to understand
<torque> the argument as I understand it is not that a + b is hard to read, it's that it's too easy to read, which means the programmer is much less likely to actually understand it
<ryuukk__> so math should be forbidden?
<ryuukk__> it's not easy to read wth
<ryuukk__> i demonstrated yesterday once your operations are long, it becomes unreadable
<ryuukk__> if all you do is a + b, .add is no big deal of course
<ryuukk__> i feel like, nobody here had to write math operations, therefore they are against the idea
<ryuukk__> hence nobody to comeup with that suggestion or concern, because it is forbidden
<ryuukk__> not allowing operator overloading = no games, no math libraries
<ryuukk__> it is essential for the ecosystem
<torque> it would be interesting if adamkowalski showed up when you were around. IIRC he was someone who initially bounced off of the no operator overloading as well
<companion_cube> well, unless you want high performance
<ryuukk__> version 0.6, it's still early, but long term will pay the price
<companion_cube> for stuff like matrices or GMP, you need to be able to specify intermediate results
<companion_cube> so + takes 3 args, not 2
<torque> he was writing a machine learning framework, which as I understand it is pretty math heavy
<torque> anyway, I think the conclusion that you can't write games or math libraries without operator overloading is a very dramatic conclusion to reach
<ryuukk__> i never said that, i said it works against that idea
<ryuukk__> it is not supportive, does not empower people to write that kind of applications
<companion_cube> people do write games in java, though
<torque> I don't know how else to interpret "<ryuukk__> not allowing operator overloading = no games, no math libraries"
<ryuukk__> you'll see in the long term
<torque> I don't think you're wrong
<companion_cube> ryuukk__: in any case it's totally incompatible with zig's explicit allocators
<torque> but I think every language has its niche and if you want a language that tries to do everything and be everything, zig is not the right candidate
<companion_cube> you just can't allocate a matrix without passing the allocator
<torque> people who chose to use zig for games etc. can make their own decision about the importance of syntactic "sugar" features like operator overloading
<torque> s/chose/choose/
<g-w1> i have a feeling a common pattern will be used and eventually it will seem normal
osa1_ has joined #zig
osa1 has quit [Ping timeout: 256 seconds]
knebulae has quit [Read error: Connection reset by peer]
osa1_ has quit [Ping timeout: 240 seconds]
osa1 has joined #zig
osa1 has quit [Ping timeout: 272 seconds]
msingle has joined #zig
xd1le has quit [Read error: Connection reset by peer]
jabb has joined #zig
xd1le has joined #zig
knebulae has joined #zig
squeek502 has quit [Remote host closed the connection]
CodeSpelunker has quit [Quit: CodeSpelunker]
marnix has joined #zig
<kandinski> I'm having trouble casting a zig string ([]const u8, as its length is only runtime known) to a c string ([c*]const u8, so I can pass it to a C library)
ur5us has quit [Ping timeout: 260 seconds]
<jabb> slice.ptr could work i think
<kandinski> it did, thanks!
<kandinski> (I forgot to report back)
<torque> if the api is actually taking a c string and doesn't take an explicit length argument along with it, it's probably expecting it to be a null-terminated string
<kandinski> torque: thanks, pcre2 does take a length
<kandinski> it's not so much the API as the compiler that was not letting me pass anything that wasn't a c-style pointer.
<torque> most sanely designed C APIs do take a length
<kandinski> my issue now is that pcre2.h uses size_t, but zig can't find it even though I've @cIncluded limits.h, stdlib.h and inttypes.h
<kandinski> error: use of undeclared identifier 'size_t'
<kandinski> pub const PCRE2_SIZE = size_t;
<torque> hm, I thought 0-sentinel slices would implicitly cast to the c string type
<torque> I think size_t is in string.h?
<kandinski> torque: at this point I don't have a slice yet, because I'm only developing, so I have compiler-konwn strings, which are Zig arrays.
<kandinski> torque: thanks!
<kandinski> torque: string.h didn't do it either, hmm
<torque> interesting
<kandinski> this is what pcre2.h.in has to say about it: https://termbin.com/gupg
<kandinski> this is where I'm currently at: https://termbin.com/a646
frmdstryr has quit [Ping timeout: 256 seconds]
frmdstryr has joined #zig
user0 has joined #zig
<kandinski> ok, fixed it by defining the size as c_int
<kandinski> now the issue is I need to pass the C library a pointer to a struct member
<kandinski> so pcre2 can write the error code, etc into my struct.
ask6155 has joined #zig
frmdstryr has quit [Ping timeout: 260 seconds]
frmdstryr has joined #zig
osa1 has joined #zig
msingle has quit [Ping timeout: 258 seconds]
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
ask6155 has left #zig [#zig]
ask6155 has joined #zig
semarie has quit [Quit: WeeChat 2.9]
semarie has joined #zig
kristoff_it1 has joined #zig
cole-h has quit [Ping timeout: 272 seconds]
marnix has quit [Ping timeout: 260 seconds]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
xd1le has quit [Quit: Quit]
ur5us has joined #zig
<daurnimator> kandinski: size_t should be in <stddef.h> I think?
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
leah2 has quit [Ping timeout: 260 seconds]
earnestly has joined #zig
marnix has quit [Read error: Connection reset by peer]
Snetry has quit [Ping timeout: 260 seconds]
marnix has joined #zig
omglasers2 has joined #zig
Snetry has joined #zig
ask6155 has left #zig [#zig]
radgeRayden has quit [Ping timeout: 272 seconds]
supercoven has joined #zig
supercoven has quit [Max SendQ exceeded]
supercoven has joined #zig
ryuukk__ has quit [Ping timeout: 264 seconds]
marler8997__ has quit [Read error: Connection reset by peer]
marler8997_ has joined #zig
bfredl has quit [Quit: killed]
alexnask[m] has quit [Quit: killed]
aterius has quit [Quit: killed]
Bastian[m] has quit [Quit: killed]
fengb has quit [Quit: killed]
Dominic[m] has quit [Quit: killed]
alva has quit [Quit: killed]
BaroqueLarouche has quit [Quit: killed]
fabio[m] has quit [Quit: killed]
DonnieWest[m] has quit [Quit: killed]
ifreund_ has quit [Quit: killed]
Snektron has quit [Quit: killed]
deltamaniac[m] has quit [Quit: killed]
Nypsie[m] has quit [Quit: killed]
return0e[m] has quit [Quit: killed]
aterius has joined #zig
leah2 has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
alva has joined #zig
DonnieWest[m] has joined #zig
return0e[m] has joined #zig
bfredl has joined #zig
alexnask[m] has joined #zig
juanfra__ has joined #zig
ifreund_ has joined #zig
Dominic[m] has joined #zig
fengb has joined #zig
BaroqueLarouche has joined #zig
fabio[m] has joined #zig
Snektron has joined #zig
Bastian[m] has joined #zig
deltamaniac[m] has joined #zig
Nypsie[m] has joined #zig
msingle has joined #zig
Kingsquee has quit []
<kandinski> daurnimator: thanks, but I tried that too and no dice
juanfra__ has left #zig ["Kicked by @appservice-irc:matrix.org : Idle for 30+ days"]
msingle has quit [Ping timeout: 244 seconds]
<semarie> kandinski: what is your OS ? stddef.h is a valid header (from posix point of vue) for having size_t . another is <sys/types.h>
tundrax has joined #zig
<tundrax> Some thoughts from a zig/rust enthusiast. Can relate on several points.
frmdstryr has quit [Ping timeout: 264 seconds]
<tundrax> Two questions I have, can someone help with?
<tundrax> 1.How to loop anonymous numbered struct fields?
<tundrax> 2. var declared inside struct block is not global, but local to struct?
<tundrax> *2: docs say that "Global variables may be declared inside a struct, union, or enum" - which is not correct?
<Nypsie[m]> 1. Take a look at std.meta.fields()
<Nypsie[m]> 2. Maybe this makes it more clear to you: https://godbolt.org/z/vaPxd9
<Nypsie[m]> sorry: pub var globalField: u32 = 5*
jjsullivan has quit [Ping timeout: 240 seconds]
<tundrax> Nypsie[m] thanks, switch is what I am using right now as well.
<tundrax> Struct global vars are not global for the module/file (out of struct scope) right?
<tundrax> Global to struct instances instead?
<Nypsie[m]> No, not to struct instance. That's what struct fields are for.
<tundrax> OK, so it's like static field for struct?
ttb has joined #zig
frmdstryr has joined #zig
<Nypsie[m]> Yeah, it's accessible from anywhere
<tundrax> Thanks.
msingle has joined #zig
Ondingen has joined #zig
<ttb> I'm a day late to the party on the operator overloading discussion. If I wanted to do extensive matrix math in Zig, I would put my matrix data into a separate set of text files and write a Zig parser that reads them, constructs the matrix structs, and converts the '+' in the files to add function calls.
<g-w1> whould this be at compile time
<kandinski> semarie: I'm on NixOS
<kandinski> but I could have been doing it wrong
<wilsonk> tundrax: great writeup on your 'scattered thoughts'. Quite comprehensive for a comparison to Rust. It could probably be used on the community wiki to direct Rust coders to the differences between the two languages, if you wanted to add it there (or perhaps ask one of he maintainers?). Anyways I enjoyed reading it! :)
donniewest has joined #zig
mkchan has quit [Ping timeout: 260 seconds]
mkchan has joined #zig
<ttb> g-w1 - I hadn't thought about using it that way, I was thinking that I would write the tool to read text files with matrices and do the operations once. Then I could run it against different inputs as needed. I don't mean to downplay the effort involved, but I think after that initial hurdle I get the same productivity with matrix manipulation as
<ttb> a language with operator overloading, minus the code readability issues.
ask6155 has joined #zig
ask6155 has left #zig [#zig]
Snetry has quit [Ping timeout: 260 seconds]
tundrax has quit [Ping timeout: 245 seconds]
osa1 has quit [Ping timeout: 240 seconds]
tundrax has joined #zig
<tundrax> wilsonk not my thoughts, this post is by another person. Anyway, I can relate to many points author talked about.
zippoh has quit [Ping timeout: 260 seconds]
tundrax has quit [Remote host closed the connection]
radgeRayden has joined #zig
ttb has quit [Ping timeout: 245 seconds]
layneson has joined #zig
Snetry has joined #zig
sawzall has quit [Read error: Connection reset by peer]
LanceThePants has joined #zig
wilsonk has quit [Quit: Leaving.]
wilsonk has joined #zig
hnOsmium0001 has joined #zig
Akuli has joined #zig
tane has joined #zig
Marrikulus has joined #zig
ask6155 has joined #zig
cole-h has joined #zig
mkchan has quit [Ping timeout: 244 seconds]
braket has joined #zig
ifreund has quit [Ping timeout: 260 seconds]
braket has quit [Client Quit]
braket has joined #zig
ifreund has joined #zig
braket has quit [Changing host]
braket has joined #zig
braket has quit [Client Quit]
braket has joined #zig
braket has left #zig [#zig]
osa1 has joined #zig
braket has joined #zig
layneson has quit [Ping timeout: 265 seconds]
ryuukk_ has joined #zig
ask6155 has left #zig [#zig]
traviss has joined #zig
<traviss> can anyone spot whats going wrong here? this is a reduction from some benchmark code that is failing in HashMap.grow on latest master:
<traviss> code and error trace is here: http://sprunge.us/FuEi8c
<traviss> forgive me for cross-posting to discord#zig
<traviss> not sure but it looks like the key 'Aani' is being mistakenly found in the newly grown map.
<traviss> just making sure i'm not doing something dumb before making an issue for this
<traviss> this was working a few monthis ago i believe was the last time i ran these tests.
msingle has quit [Read error: Connection reset by peer]
Snetry has quit [Ping timeout: 240 seconds]
Snetry- has joined #zig
Snetry- has quit [Ping timeout: 240 seconds]
Snetry has joined #zig
layneson has joined #zig
squeek502 has joined #zig
gazler has quit [Quit: Leaving]
Snetry has quit [Quit: left Freenode]
Snetry has joined #zig
wilsonk has quit [Quit: Leaving.]
wilsonk has joined #zig
gazler has joined #zig
wilsonk has quit [Client Quit]
wilsonk has joined #zig
wilsonk has quit [Quit: Leaving.]
wilsonk has joined #zig
xackus has joined #zig
wilsonk has quit [Client Quit]
wilsonk has joined #zig
wilsonk has quit [Client Quit]
wilsonk has joined #zig
wilsonk has quit [Client Quit]
wilsonk has joined #zig
<Sahnvour> traviss: StringHashMap accepts slices as keys, but it does not own copies of the strings, you have to allocate them yourself
<Sahnvour> in this example all your hashmap keys are slices pointing more or less to the same memory address which is reused with new contents
braket has quit [Ping timeout: 265 seconds]
<Sahnvour> it happens to work for insertion up to a certain point but it's not correct
braket has joined #zig
braket has quit [Changing host]
braket has joined #zig
<traviss> thank you. i wondered if something like this was happening. makes perfect sense now. i forgot about allocating keys.
layneson has quit [Quit: WeeChat 2.8]
layneson has joined #zig
osa1 has quit [Ping timeout: 256 seconds]
<tane> I had some "old" zig code using std.Buffer and std.io.readLine. All stuff is gone, where is it?
frett27 has joined #zig
Snetry has quit [Ping timeout: 258 seconds]
Snetry has joined #zig
leah2 has quit [Ping timeout: 244 seconds]
wootehfoot has joined #zig
layneson has quit [Ping timeout: 240 seconds]
braket has quit [Ping timeout: 246 seconds]
braket has joined #zig
braket has quit [Changing host]
braket has joined #zig
braket has quit [Client Quit]
skuzzymiglet has joined #zig
xackus has quit [Ping timeout: 265 seconds]
Snetry has quit [Ping timeout: 256 seconds]
Snetry has joined #zig
leah2 has joined #zig
ur5us has joined #zig
<wilsonk> tane: I think you can use const stdin = std.io.getStdIn().inStream(); and then stdin.readUntilDelimiterOrEof instead of readline. Also, perhaps you can use the new General Purpose Allocator to get a dynamic buffer (or use an array for a static buffer)
<g-w1> is there a way to access a [*]i64 at a negative index
<tane> wilsonk, thanks for the pointers!
<g-w1> im writing zig as a library to assembly so i know where the memory is.
<g-w1> i kinda screwed up the assembly, so i want the negative index to unscrew myself up
<g-w1> actually nvm
<g-w1> i want it to be compatible with the c abi
Snetry has quit [Ping timeout: 264 seconds]
Snetry has joined #zig
skuzzymiglet has quit [Read error: Connection reset by peer]
xackus has joined #zig
Snetry has quit [Ping timeout: 260 seconds]
Marrikulus has quit [Quit: WeeChat 1.9.1]
Snetry has joined #zig
Snetry has quit [Ping timeout: 258 seconds]
marnix has quit [Ping timeout: 264 seconds]
Snetry has joined #zig
marnix has joined #zig
gazler has quit [Remote host closed the connection]
Kingsquee has joined #zig
Akuli has quit [Quit: Leaving]
CodeSpelunker has joined #zig
ivancr72 has joined #zig
GregVardy has joined #zig
tane has quit [Quit: Leaving]
wootehfoot has quit [Read error: Connection reset by peer]
GregVardy has quit [Remote host closed the connection]
donniewest has quit [Quit: WeeChat 2.9]
marnix has quit [Ping timeout: 256 seconds]
ivancr72 has quit [Remote host closed the connection]
<justin_smith> g-w1: worst case you can cast to integer and back, but it seems weird to end up in that position
<g-w1> yeah. i messed up my assembly (had the stack backwards in my head) and figured it would be easier to fix it from zig, but i can just fix it in assembly with a little more work.
frett27 has quit [Ping timeout: 260 seconds]
mkchan has joined #zig
frmdstryr has quit [Ping timeout: 256 seconds]
omglasers2 has quit [Read error: Connection reset by peer]
daurnimator has quit [Quit: WeeChat 2.9]
CodeSpelunker has quit [Read error: Connection reset by peer]
daurnimator has joined #zig
Ondingen has quit [Remote host closed the connection]
AlbinoDrought_ has joined #zig
AlbinoDrought has quit [Ping timeout: 272 seconds]
<ikskuh> Nypsie[m], mattnite, aurame and me did a thing: https://zpm.random-projects.net/
<ikskuh> Please contribute your packages to the main repository so other ziguanas can find and use them!
AlbinoDrought_ has quit [Ping timeout: 260 seconds]
AlbinoDrought has joined #zig
AlbinoDrought has quit [Changing host]
AlbinoDrought has joined #zig
frmdstryr has joined #zig
tundrax has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
ryuukk__ has joined #zig
ryuukk_ has quit [Read error: Connection reset by peer]
nullheroes has quit [Quit: WeeChat 2.9]
ur5us has joined #zig
<kandinski> Is there a way to reserve a space in a struct for a slice that will be filled at runtime?
<kandinski> the context is an error string that will be filled by a C library, and I want to store it as a slice, but I need to reserve the maxsize of all potential error messages.
jayschwa has joined #zig
ryuukk__ has quit [Read error: Connection reset by peer]
<jayschwa> A slice is just a pointer and a length. A slice by itself does not contain a buffer. If you want to have a buffer inside your struct, then you'll have to have a field of type [maxsize]u8.
frmdstryr has quit [Ping timeout: 272 seconds]