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/
<kristoff_it1> the best you can do is lisp, but even then it's still macros
a92 has joined #zig
<jabb> carp is possible something
<jabb> but other lisps you lose being close to the metal
mschwaig has quit [Quit: WeeChat 2.7.1]
<ifreund> yeah, zig is awesome
mschwaig has joined #zig
<frmdstryr> How can I get the current thread name?
<frmdstryr> Oh, nvm std.Thread.getCurrentId
<andrewrk> hello
<jabb> yo!
<jabb> how're you?
<andrewrk> I'm ok. I won't be able to be at full productivity until I get this situation worked out, but I'm not in any physical danger anymore
<andrewrk> I have a few hours to spare now to work towards the release :)
<jabb> nice. yeah i saw it on twitter. sucky situation. glad you're okay
<ifreund> good to see you back on IRC, been a litte worried
<g-w1> One thing that I got confused about was in rust `variable: &Type` is equavalent to `Type *variable`. But in zig it is equavelent to `variable: *Type` why is this?
<g-w1> in the second example i am reffereing to c
<ifreund> I'm not sure I understand the question
<a92> Zig chose Rust-like syntax for variable/parameter declaration but C-like syntax for pointer types. Languages do strange things sometimes.
<g-w1> I am confused why rust uses &Type and zig uses *Type
mschwaig has quit [Quit: WeeChat 2.7.1]
<a92> Just syntax choices; they don't have to be the same
<g-w1> It made sense with c because the * was on the variable so i thought it was equavalent to the & being on the type
<g-w1> oh
<g-w1> ok
mschwaig has joined #zig
<ifreund> oh rust has * pointers too, they're different though
<andrewrk> g-w1, we used to have &Type for pointers
<g-w1> ok
<g-w1> it makes sense that its just a syntax decision
<andrewrk> we had to change it because in zig types are values and so &T was ambiguous
<g-w1> that makes sense
<daurnimator> TIL
squeek502 has quit [Remote host closed the connection]
ryuukk__ was banned on #zig by ChanServ [ryuukk__!*@*]
ryuukk__ was kicked from #zig by ChanServ [Banned: bad vibes]
Kena has quit [Remote host closed the connection]
Axiomatic has joined #zig
AceNovo has quit [Remote host closed the connection]
<Axiomatic> @kandinski np ... its crazy that even a nominally simple concept like determining the sign of a numeric quantity is so complex, but there you have it
a92 has quit [Quit: Leaving]
<ifreund> man, why did someone add zig support to code.golf
<ifreund> i have wasted too much time already :D
ryuukk_ has joined #zig
<ifreund> I can't figure out how to drop 2 more characters and it's annoyingme
<andrewrk> does it let you see others' solutions?
<pixelherodev> andrewrk: what happened, are you okay?
<andrewrk> let's keep it on topic here but feel free to dm me
mschwaig has quit [Read error: Connection reset by peer]
<ryuukk_> ChanServ has kicked ryuukk__ from #zig (Banned: bad vibes)
<ryuukk_> what does that mean?
<ryuukk_> i have very unstable connection since few weeks ago, server is probably flagging me as bot
mattnite has joined #zig
ryuukk_ was kicked from #zig by ChanServ [Banned: bad vibes]
<Axiomatic> Odd that anyone even programmed a bot to detect vibes. Seems like it would be difficult to debug...
<pixelherodev> Obviously, the first sign of bad vibes is questioning the bot's decisions ;)
<pixelherodev> I for one welcome our new glorious bot overlord
<Axiomatic> (Praise the Bot)
<ifreund> andrewrk: it lets me see how many characters/bytes they used, but not their code
<andrewrk> interesting decision. I think it makes sense although it's a shame, it seems like a missed learning opportunity
<ifreund> I am 2 bytes away from first place for the "beer on the wall" problem
<daurnimator> ifreund: link?
<ifreund> honestly I'm happy with the way they did it. It's the best way to encourage competition I see
<ifreund> I know that improvement is possible but I have to arrive at the solution myself
<pixelherodev> ifreund: can you use the standard library in that?
<pixelherodev> Or is it language only?
<ifreund> you can use the std, you need to print to stdout :P
<pixelherodev> Ah right
<fengb> What if I make a PR to stdlib to solve this? 🤔
<pixelherodev> ... have you tried using compression? ;P
<fengb> std.beers()
<ifreund> that's basically what I did yeah
dbandstra has joined #zig
<ifreund> though I kinda hit a dead end
Guest47 has joined #zig
earnestly has quit [Ping timeout: 240 seconds]
<ifreund> could just be that my by-hand compression wasn't optimal
<Guest47> Ok, so i checked log, and i got banned by individual, that's OK, i would have prefered to be told prior to that so i could perhaps work on what the "issues" i have caused, that would have been more polite and more adult from whoever banned me, i will not come back since, apparently, sharing 1st experience or frustrations is too much for whoever
<Guest47> decided to ban me, and that's ok, i respect that choice, even if i disagree with it, but that's life, i wish good luck to this project, and maybe consider speaking to whoever banned be to maybe be less emotive
<ifreund> Guest47: mostly likely your tone regarding the docs a couple hours ago
<Guest47> (ryuukk is my username on IRC, just to be precise)
<ifreund> you came across quite entitled
<Guest47> that is private document, draft that i decided to share with you, i had warned about it being my ranting over frustration, but it's okay, i shared it with you it is my fault, anyways, i don't want cause more issues, i will just leave and respect the ban inflicted
CmdrCrisp has quit [Ping timeout: 260 seconds]
x2C25 has quit [Ping timeout: 260 seconds]
Guest47 has quit [Quit: Connection closed]
Axiomatic has left #zig ["Leaving"]
<andrewrk> thank you I appreciate that. if you want to, come back in about a year, and let's see how things go. 211 people in this channel, there is a high expectations of behavior
<andrewrk> getting banned from this channel doesn't mean you are a bad person. this channel is an experiment with a trigger happy ban hammer
<andrewrk> and I know that's a juicy subject but let's resist meta discussion temptations and redirect the topic back to zig coding
mattnite has quit [Ping timeout: 245 seconds]
lanodan has quit [Quit: WeeChat 2.9]
<daurnimator> ifreund: beat you :)
<ifreund_> daurnimator: nicely done :)
<ifreund_> it’s 4am here so i’m gonna have to sleep before my brain stops working entirely:D
notpiika_ has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
<andrewrk> good night
<daurnimator> not sure if I should share my answer? I guess that's not in the spirit of the game...
notpiika has joined #zig
xackus has quit [Ping timeout: 240 seconds]
klltkr has quit [Ping timeout: 260 seconds]
lanodan has joined #zig
x2C25 has joined #zig
earnestly has joined #zig
dbandstra has quit [Ping timeout: 258 seconds]
marnix has joined #zig
kristoff_it1 has quit [Ping timeout: 240 seconds]
dbandstra has joined #zig
dbandstra has quit [Client Quit]
lucid_0x80 has joined #zig
lucid_0x80 has quit [Quit: Leaving]
lucid_0x80 has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
lucid_0x80 has quit [Ping timeout: 260 seconds]
frett27 has quit [Ping timeout: 260 seconds]
osa1 has joined #zig
Stephanie has quit [Quit: Fuck this shit, I'm out!]
Stephie has joined #zig
cole-h has quit [Ping timeout: 256 seconds]
decentpenguin has quit [Read error: Connection reset by peer]
decentpenguin has joined #zig
ur5us has joined #zig
mmohammadi9812 has joined #zig
marnix has quit [Remote host closed the connection]
marnix has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
ask6155 has joined #zig
tane has joined #zig
squeek502 has joined #zig
tundrax has joined #zig
gazler_ has joined #zig
FireFox317 has joined #zig
gazler__ has quit [Ping timeout: 260 seconds]
kristoff_it1 has joined #zig
kristoff_it2 has joined #zig
kristoff_it1 has quit [Ping timeout: 260 seconds]
mmohammadi9812 has quit [Ping timeout: 256 seconds]
mmohammadi9812 has joined #zig
Kingsquee has quit []
mmohammadi9812 has quit [Ping timeout: 246 seconds]
mmohammadi9812 has joined #zig
ask6155 has left #zig [#zig]
<kandinski> hi folks, I have an array of c pointers into a u8 buffer (pcre2 matches into a string), and I want to turn it into a slice of slices of u8. I guess I could write C-like code, but I was hoping I could cast the buffer into an array of 2-pointer structs, and then iterate through it using a function on the 2-pointer struct to output a Zig slice.
dddddd has quit [Ping timeout: 260 seconds]
<kandinski> I'd appreciate a tip on how to proceed. I don't know if I'm complicating my life too much.
<ifreund> hmm, I'm not sure if you can do this in place without UB as I don't think slices have a well defined memory layout
<ifreund> yeah, "packed" slices aren't planned: https://github.com/ziglang/zig/issues/2201
<kandinski> ifreund: yeah, I misspoke, I need to do this in two steps
<ifreund> If you want to transform it to a slice of slices you'll need to allocate your own array then and copy the data over
<kandinski> one, cast the array of c pointers into a known-length array of zig structs
<kandinski> then I can iterate over it and generate the second array as you say
<ifreund> i'd skip step one, it seems like an overcomplication
<ifreund> just iterate 2 at a time
<kandinski> for every pair of c pointers, I do whatever I need to generate a []u8, and I copy that to the mmh
<kandinski> sure
<kandinski> you're right, of course
dddddd has joined #zig
<kandinski> I know the number of captures, so I can:
<ifreund> it'd be need it this were doable in place though, a packed slice would be exactly the size of 2 pointers
<kandinski> - build an array of slices of the subject string
<ifreund> s/need/neat/
<kandinski> - rewrite each slice's pointer and length as I iterate over the pcre2's ovector
<kandinski> well, ifreund it's not that easy because my zig function can allocate and return an array on the stack, and then free the pcre2 ovector which is in the C heap
<kandinski> thanks for helping me work through it
<ifreund> the length is known at compile time?
<kandinski> no
<kandinski> it's known at runtime only
<kandinski> because it's as long as the number of matches/captures
<ifreund> you probably need to allocate the zig array of slices then
<kandinski> why so?
<ifreund> stack variables must have a compile time known size
<kandinski> I thought zig could make caller allocate
<kandinski> aaah
<kandinski> so it goes
<kandinski> so yes, it will be compile time known, because it will be a pointer into heap memory
<kandinski> so it goes
<ifreund> just take an allocator as a parameter
<kandinski> for now I'm not even doiong that, because pcre2 uses the c heap already
<kandinski> (there's a way to pass an allocator to it, but I'll figure that out once I get it working)
<ifreund> then just hardcode std.heap.c_allocator for now I guess :D
<kandinski> yup, I already have a deinit() fn cleaning up after pcre2, it might as well clean up after me
<kandinski> thanks
<nyaayaya> Is it possible to do something like this in Zig?
<nyaayaya> const a=1, b=2, c=3;
<nyaayaya> (instead of const a=1; const b=2; const c=3;) @.@
<Nypsie[m]> No
<kandinski> (that was silly of me: of course caller can only stack-allocate values of compile-time-known size)
<nyaayaya> oh, ookie ^^
<nyaayaya> thank you
<ifreund> cosnt out = std.heap.c_allocator.alloc([]u8, N); var i: usize = 0; while (i < N) : (i += 2) out[i/2] = in[i][0..in[i+1]-in[i]]; return out;
<kandinski> ifreund: thanks
<Nypsie[m]> nyaayaya: Would be nice, but goes against Zig's zen :)
<nyaayaya> Nypsie[m]: Ah, right. "Only one obvious way to do things."
<ifreund> yep :)
<ifreund> also, where would you put the types?
<nyaayaya> const a: u32 = 1, b: u32 = 2; ?
<ifreund> hmm, is a for loop cleaner? for (out) |*o, i| o.* = in[2*i][0..in[2*i+1]-in[2*i]];
burkac has joined #zig
<kandinski> ifreund: of course
<ifreund> nyaayaya: yeah I guess, but then you loose out even more on readability
<kandinski> I couldn't figure how to iterate through in, but I don't need to
<kandinski> well, I can iterate through out and make the iteration code more readable
<ifreund> and without great benefit as you can't "share" the type between the variables
<kandinski> I think I can figure it out now
<ifreund> :)
<kandinski> or I can use pointer arithmetic against the start of the regex target buffer, and just slice the buffer
mmohammadi9812 has quit [Ping timeout: 256 seconds]
mmohammadi9812 has joined #zig
<kandinski> anyway, thanks very much
osa1 has quit [Ping timeout: 256 seconds]
mmohammadi9812 has quit [Ping timeout: 260 seconds]
<nyaayaya> ifreund: yay, solved it (444 bytes). but geh, if there would be a way to join const declarations together :(
mmohammadi9812 has joined #zig
<ikskuh> uuuh, let me join in! :D
<Nypsie[m]> This looks fun! I will try it too tonight
<earnestly> That website does not show any code for me
<earnestly> Perhaps that's the point
<Nypsie[m]> That is indeed the point :P
<ifreund> nyaayaya: congrats! I've decided that I suck at golf :P
<ifreund> gonna get back to work on river and related projects
<fengb> Nah, practice makes perfect :P
<ikskuh> okay, i have a working solution, 799 bytes :D
marnix has quit [Ping timeout: 260 seconds]
marnix has joined #zig
<kandinski> hey ifreund, I got it working. The two first comments in this are just for you, but the rest is because I prefer to let the compiler do the code golf and I write as readable as possible: https://termbin.com/9578
<kandinski> ifreund: tips on style and performance very welcome
<g-w1> why does standardReleaseOptions() require libc
<g-w1> I am trying to write an only static executable and it is saying stuff like `undefined reference to memcpy`
<g-w1> and the weird thing is I just changed the name of the library and now it requires libc
<ikskuh> g-w1, standardReleaseOptions should not require libc
<ikskuh> can you show the build fle?
<g-w1> yes
<g-w1> lemme do a scrot
<ikskuh> ifreund: did you use std.debug.print or proper stdout writing?
<g-w1> ill put pastebin of `nm zig-cache/lib/libstd.a`
<ikskuh> looks fine so far
marnix has quit [Read error: Connection reset by peer]
<ikskuh> can you post the full error output?
marnix has joined #zig
<g-w1> yeah
<g-w1> here is the output from nm https://share.olind.xyz/f.php?h=32mk6OXG&d=1
<g-w1> you can see it uses libc symbols
<kandinski> ifreund: this is still rough af, and I only plan to implement just what I need for now and move on to the rest of the make-a-lisp project before coming back and cleaning up, but I'm pretty chuffed of the progress in just one week and the two weekends at both sides: https://github.com/candeira/mal/blob/zigzug-wip/impls/zigzug/re.zig
<kandinski> wat
<g-w1> i fixed this problem before by turning on release mode but I shouldn't have to do that, right? https://i.imgur.com/ygESQM1.png
<g-w1> here is the ld errorss
<ifreund> ikskuh: you need to write to stdout :/
<ifreund> which takes a lot of bytes with zig
<ikskuh> :D
<ikskuh> yeah i figured
<g-w1> do you have an idea why it is linking against something else, maybe libc
<ikskuh> it is not linking against libc
<ikskuh> but the compiler is spilling mallocs as optimizations for larger copy operations
<g-w1> interesting.
<ifreund> kandinski: looking good :) I'm sure you'll find thing you can improve upon through real-world usage
<g-w1> so I guess I have to turn on release mode to get rid of it
<ikskuh> g-w1: i don't think that will help
<ikskuh> it really depends on your code
<g-w1> i helped before, but I wanted to have standard mode, and then it broke again
<ikskuh> memcpy and stuff are part of compiler_rt
<ikskuh> you might need to bundle/link against it as well
<ikskuh> lib.bundle_compiler_rt = true
<g-w1> ok
<ikskuh> should do the job
<kandinski> ifreund: sure! I'd like to eventually have something others can use, but for now I feel this is a well shaved yak and I'm going to move on as long as I get the results I need
<g-w1> i think it works with builtin.Mode.ReleaseFast
<kandinski> ifreund: thanks so much for your support and advice
<ikskuh> ha, finally sub-600 :)
<g-w1> well now it works with release-fast mode enabled. ill file this in the back of my head as a potential bug
<ifreund> kandinski: no problem!
<ikskuh> ifreund: the one thing that bugs me is that darn "No more bottles" ;D
<ikskuh> g-w1: does it work with standard mode?
<ikskuh> so Debug=
<ifreund> ikskuh: I got bored of that one, I'm working on the brainfuck one now :D
<ikskuh> heh
<ikskuh> will check that out as well
<g-w1> do you think this is the best way to embed zig in a rust project? https://paste.rs/k1B.rs as a build.zig
<ikskuh> but right now, i want to get at least down to ~550
osa1 has joined #zig
frmdstryr has quit [Read error: No route to host]
<ifreund> damn, daurnimator got down to 414
<ifreund> I'm so curious
<ikskuh> yeah, me too
<ikskuh> i just discovered something which requires an issue on github though
<g-w1> what?
<ikskuh> we're playing code golf
<g-w1> I mean what reqires an issue
<ikskuh> oh
<ikskuh> you'll see :D
frmdstryr has joined #zig
* virkony just noticed that EAGAIN in std.os.fork translated to error.SystemResources, which seems to be wrong...
<ikskuh> EAGAIN A system-imposed limit on the number of threads was encountered. There are a
<ikskuh> number of limits that may trigger this error:
<ikskuh> sounds about right
<virkony> ikskuh: true, man says that. but I had impressions that EAGAIN or something like that can occur when syscall interrupted
<g-w1> thanks
<g-w1> nice issue!
<ikskuh> virkony: this yields ERESTARTNOINTR :D
<virkony> my bad, I mistook it for EINTR :)
* virkony realized that one of the recent comment he left was most likely missing handling EINTR
sawzall has quit [Read error: Connection reset by peer]
sawzall has joined #zig
tundrax has quit [Remote host closed the connection]
braket has quit [Quit: Ping timeout (120 seconds)]
braket has joined #zig
braket has joined #zig
braket has quit [Changing host]
donniewest has joined #zig
mschwaig has joined #zig
mschwaig has quit [Ping timeout: 272 seconds]
ask6155 has joined #zig
frmdstryr has quit [Remote host closed the connection]
frmdstryr has joined #zig
Akuli has joined #zig
<ifreund> ok, I don't understand this. My brainfuck golf produces the exact output that is expected but it gets marked as failing
<ifreund> ugh, I forgot to skip argv[0] but it wasn't producing any output as there are no brainfuck symbols in it normally
<tane> are you testing your implementation of a BF interpreter?
<ifreund> tane: I'm playing this: https://code.golf/brainfuck#zig
<g-w1> is there a way to do a for loop for a known amount of iterations without creating an array?
<dutchie> var i: usize = 0; while (i < numIters) : (i += 1) { ... }
<g-w1> ok
<ifreund> there's also a hacky way to use a for loop with a slice of 0 bit types
<g-w1> you have to create a variable
<ifreund> but a while loop is the right answer
<g-w1> ok
<dutchie> it feels like zig's while look with a continue expression is closer in spirit to C's for
<dutchie> loop*
<ifreund> it's kinda halfway between C's while and for
<tane> I kinda dislike that the loop indices litter the enclosing namespace, similar dependence for "err" variables in go, making it hard to copy code segments around
<g-w1> could you enclose everything in a {}
<tane> sure
nvmd has joined #zig
<travv0> yeah one thing i wish was in zig is `while (var i: usize = 0...) {...}` syntax so that the i is only accessible inside the loop
<travv0> but obviously that's not consistent with how variable initialization works anywhere else in the language
skuzzymiglet has joined #zig
<ifreund> I've slowy come to realize that it doesn't matter too much to me in practice
<nyaayaya> hmm
hnOsmium0001 has joined #zig
<nyaayaya> zig\lib\zig\std\os\windows.zig:1442:20: error: unable to evaluate constant expression
<nyaayaya> .x86_64 => asm volatile (
<nyaayaya> works on FreeBSD
<nyaayaya> :(
<nyaayaya> (on Windows: Zig 0.6.0+91a1c20e7, latest "master" build)
<nyaayaya> (full stacktrace: https://paste.rs/8tF.C)
<ifreund> #1 in brainfuck :)
<nyaayaya> wowowo
<nyaayaya> I've tried to solve Fizzbuzz... but got stuck with this weird Windows error
<nyaayaya> :(
<ifreund> maybe try using the % operator instead of @mod?
<nyaayaya> hmm, but how is this related to [.x86_64 => asm volatile (]?
<nyaayaya> because it looks like it's caused by getStdOut.writer()
<ifreund> nvm, just looked at the stack trace
<g-w1> I am getting expected type *std.mem.Allocator found *const std.mem.allocator
<g-w1> what am i doing wrong
<nyaayaya> (also wouldn't it cause that error with int_comptime and u8?)
<dutchie> you need to declare your allocator as a var not a const
<ifreund> maybe passing the allocator by value instead of by pointer?
<g-w1> oh
<g-w1> ill try that
<g-w1> it doesn't work
<ifreund> paste the code somewhere?
<nyaayaya> [https://paste.rs/8tF.C] so uhhuh, it looks like a problem with std/os/windows.zig @.@
Kena has joined #zig
<ifreund> that doesn't make much sense
TheLemonMan has joined #zig
<Kena> Hey dutchie, why do you declare a `usize` to iterate through a for loop insteand of a integer? I do not grasp the role or at least use case for usize data type.
<TheLemonMan> nyaayaya, the compiler is trying to execute your code at compile-time
<TheLemonMan> try replacing `const p` with `var p`
<nyaayaya> oh
<nyaayaya> like this?
<TheLemonMan> yep
<g-w1> here is the error https://paste.rs/xJA
<fengb> Kena: usize is the “natural” pointer size of the architecture. It’s what slices use internally
<fengb> It’s the equivalent of size_t from C
<nyaayaya> TheLemonMan: whoa, it works now. Thankiee
<Kena> But I thought a pointer point to a memory address, how it is related to a size?
<TheLemonMan> Kena, it's wide enough to represent any object in memory
<nyaayaya> also it doesn't warn when `var p [...]` is outside main() (top-level declaration?)
<fengb> Pointers have a fixed size in CPUs, 32 bit in x86 and 64 bit in x64
<ifreund> a memory address has a size, usize is that size
<nyaayaya> and prints the same error (unable to evaluate constant expression)
<Kena> told you I was a noob :D Thank you.
<fengb> On modern CPUs it’s usually the fastest and most natural size
<earnestly> Kena: (If you want to rabbit hole: https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models )
<fengb> (Note that this is not true for older / embedded systems)
<TheLemonMan> that's not always true, it also depends on the ABI. eg the x32 abi is the usual x64 one with 32bit pointers
<g-w1> figured it out (too many consts) :)
<nyaayaya> TheLemonMan: uhm, [https://paste.rs/eEk.c] compiles and runs on FreeBSD
<nyaayaya> why e.e
<TheLemonMan> because getStdOut is implemented differently on Windows
<fengb> Windows is the reason it’s even a function :(
<TheLemonMan> on unix-derived systems we simply use the STDOUT_FILE handle
<Kena> Does it mean a u128 integer cannot be pointed to?
<TheLemonMan> on Windows we have to scavenge into the thread-local kernel block to get the std{in,out,err} handles
<dutchie> Kena: usize is an integer type. you can loop with any integer you want
<nyaayaya> huhh
<earnestly> Kena: It refers to the range of memory it can point to, e.g. on 32bit systems a pointer can only address up to 4G
<nyaayaya> Thank you again ^^
<earnestly> Kena: I.e. 2^32
<earnestly> (2^32-1 if you want to start at 0)
<Kena> Thanks a lot, I'm happy to learn
<dutchie> half-tempted to benchmark looping with different sized integers to see if it makes any difference
xackus has joined #zig
<ifreund> it would be very dependant on your exact cpu and whatever llvm decides to do
waleee-cl has joined #zig
<earnestly> Kena: (Though keep in mind that a pointer also typically bound by PTRDIFF_MAX if you wish to do pointer arithmetic)
<earnestly> Kena: This is a pretty nice article as it also gives you a table of the data models: https://www.viva64.com/en/a/0050/
mschwaig has joined #zig
<Kena> I'm grateful earnestly, but it deal about size_t and ptrdiff_t, those are not primitive types in Zig, are they?
<earnestly> Kena: They are specific to the machine
<earnestly> Kena: zig has their own versions of them
<Kena> Allright, I'd rather read it now :)
<earnestly> Kena: Although zig uses slices instead of pointer arithmetic for addressing arrays, but what those things represent are the nature of the beast if you want to understand a bit about what's going on under the hood
<Kena> I would love to as I want to use a non-GC low level language ^^
<ifreund> also Zig isn't perfect yet, see https://github.com/ziglang/zig/issues/5185
<earnestly> ifreund: Issues like this make me appreciate Ada more
<earnestly> Even though I don't use it
<earnestly> Ada with comptime would be delightful (which is sort of achieved with spark but it's a hassle and far more involved)
tane has quit [Quit: Leaving]
<g-w1> is there a way to remove all items from an ArrayList
<ifreund> foo.items.len = 0;
<g-w1> nice
<g-w1> i like how an array list also gives u the raw memory
<ifreund> yeah, it has quite good ergonomics but doesn't hide any of the details from you
<Kena> Does reassign the length to 0 need free the manually memory somewhere? like deinit or something
<Kena> freeing*
<ifreund> Kena: no, the capacity field traks how much memory is allocated by ArrayList
<ifreund> you shouldn't set that one manually
<Kena> Allright :)
<justin_smith> there might be an issue with nested collections, as with any arbitrary container
<ifreund> yes, if your elements own memory setting items.len to 0 would leak
frmdstryr has quit [Ping timeout: 240 seconds]
lucid_0x80 has joined #zig
frmdstryr has joined #zig
Cloudef has quit [Quit: ZNC - http://znc.in]
Cloudef has joined #zig
tane has joined #zig
dumenci has joined #zig
lucid_0x80 has quit [Ping timeout: 256 seconds]
ask6155 has left #zig [#zig]
lucid_0x80 has joined #zig
dumenci has quit [Ping timeout: 240 seconds]
zippoh has joined #zig
cole-h has joined #zig
<Kena> In the doc regarding to the optional pointer, please why does the address 0 cannot have a value? It may be a stupid question.
<Kena> It has value null I admit, but why it is this only value allowed? That why I mean.
<justin_smith> Kena: do any architectures supported by zig allow storing a value at 0?
<justin_smith> if so, not being able to write to location 0 is a limitation, but I was under the impression that no modern architectures allowed storage to 0
<fengb> wasm, freestanding
<fengb> You can do `*allowzero T` for a zero friendly pointer
x2C25 has quit [Ping timeout: 260 seconds]
<Kena> You're right, I missed that mechanic.
<Kena> I did'nt know it could be a use case for wasm though.
sawzall has quit [Read error: Connection reset by peer]
sawzall has joined #zig
<Kena> Please what does 'prong' means? E.g. "A switch on a non-exhaustive enum can include a '_' prong as an alternative to an else prong..."
<CommunistWolf> case
<CommunistWolf> i.e. the different possible execution paths, each is a prong, like on a fork
<ifreund> switch (foo) { .abc => {}, .xyz => {}, _ => {});
<ifreund> messed up the braces but you get the idea
<Kena> Ah yes, it's more clear now, thanks =)
<Kena> In the doc, when it is said "safety-checked undefined behaviour", does it mean the compiler prevent undefined behaviour from happening? Or is it executed nonetheless with some kind of possible recovery mechanism for the user?
<ifreund> that means that in safe build modes the compiler will add extra code to check for UB at runtime and abort if it occurs
<ifreund> in fast modes UB means literally anything could happen, you can only hope your program crashes
<Kena> Nice ^^ Does it include debug mode too?
<ifreund> yes, Debug and ReleaseSafe
<Kena> Thank you.
<Kena> But it also bloat the size right?
<ifreund> yes
<ifreund> though this is a very reasonable tradeoff in most cases
<andrewrk> sometimes the optimizer (llvm) figures out it can delete some safety checks
<Kena> is ReleaseSafe a viable option for a production environment?
<ifreund> and you can enable ReleaseFast for only some functions if you need
<ugla> And in any mode where @setRuntimeSafety(true) is used, I assume?
<ifreund> yes, release safe is a totally vaild default, it's what I use 99% of the time
<Kena> Allright.
<ifreund> it's not as fast or small as release fast/small, but it's by no means slow :D
<TheLemonMan> proposal: rename ReleaseFast to YOLO
<nyaayaya> ReleaseSmol
<Kena> accepted for milestone 0.8.0 :D
lucid_0x80 has quit [Ping timeout: 240 seconds]
<g-w1> releasefast is crazy fast.
<jabb> i think it would be cool to have a noop function generator to avoid null function pointers, like @noop({}). this will help with interface declarations where you want default functions
<jabb> i end up just making a bunch of stub functions and assigning them so i don't have to pass every function
xackus has quit [Ping timeout: 260 seconds]
<andrewrk> ifreund, my goal is to get all the breaking changes for 0.7.0 in by tomorrow evening at the latest, and then only bug fixes & stability issues from then until the tag is cut. hopefully river can be in a good place to stick with 0.7
<andrewrk> TheLemonMan, how's it going? nice seeing you around again
<TheLemonMan> andrewrk, not good, not bad, I'm quite busy with my master thesis but I always find some time for some Zig hacking
<ifreund> what's your thesis on?
<TheLemonMan> innovative topologies/design for high-efficiency power amplifiers
<jabb> :O
<andrewrk> wow
<ifreund> that sounds like electrical engineering not CS :P
<jabb> i'm sure there's some machine learning involved
<TheLemonMan> yep, I'm a EE with a penchant for CS
<fengb> Is zig somehow involved too? >_>
<TheLemonMan> only a boatload of Matlab *sad trombone*
<justin_smith> looking for some help decyphering a compiler error: "expected type '[]audio_node.Node', found '[2]audio_node.Node'"
<ifreund> andrewrk: I appreciate it! My fancy new bindings using opaque{} for libwayland and wlroots and related are now working and just need a bit of cleanup before I bring them into river :)
<ifreund> justin_smith: try &foo
<TheLemonMan> justin_smith, you need a &
<g-w1> how should I represent a tuple as a type?
<g-w1> .{ bool, u32, usize, usize } this does not work
<justin_smith> ifreund: TheLemonMan: thanks, that's the trick
<TheLemonMan> g-w1, meta.Tuple
<g-w1> ok
<g-w1> thx
<ifreund> it's saying that it expects a slice but found an array, using & will give you the address of the array which can coerce to a []foo slice
xackus has joined #zig
<justin_smith> ifreund: aha, that was my confusion, I thought my literal was a slice
wootehfoot has joined #zig
<ifreund> yeah, arrays are values in zig
cole-h has quit [Quit: Goodbye]
cole-h has joined #zig
<Kena> does the concept of dynamic array exist in Zig? Or is it more or less the slice?
<g-w1> std.ArrayList
<g-w1> also, how does returning an array work at the assembly level, this has confused me for a while?
<TheLemonMan> read a bit on NRVO
<g-w1> ok
<Ristovski> Is there an alternative to std::multimap/std::unordered_multimap in Zig?
klltkr has joined #zig
osa1 has quit [Ping timeout: 240 seconds]
frett27 has joined #zig
donniewest has quit [Read error: Connection reset by peer]
donniewest has joined #zig
radgeRayden has joined #zig
mmohammadi9812 has quit [Read error: Connection reset by peer]
mmohammadi9812 has joined #zig
x2C25 has joined #zig
burkac` has joined #zig
riba has joined #zig
burkac has quit [Ping timeout: 240 seconds]
nvmd has quit [Ping timeout: 272 seconds]
burkac` has quit [Remote host closed the connection]
frmdstryr has quit [Ping timeout: 240 seconds]
ur5us has joined #zig
<g-w1> TheLemonMan: thanks, I read about a "return slot" and that cleared it up.
<kandinski> ifreund: I added more test yesterday and I'd forgotten that I was only capturing the first match. Woops.
<kandinski> 12:47 < ifreund> kandinski: looking good :) I'm sure you'll find thing you can improve upon through real-world usage
<kandinski> p r o p h e t i c
frmdstryr has joined #zig
aperezdc[m] has quit [*.net *.split]
Nypsie[m] has quit [*.net *.split]
euantorano has quit [*.net *.split]
Sahnvour has quit [*.net *.split]
letoram has quit [*.net *.split]
euantorano has joined #zig
Sahnvour has joined #zig
letoram has joined #zig
riba has quit [Ping timeout: 260 seconds]
aperezdc[m] has joined #zig
Nypsie[m] has joined #zig
klltkr_ has joined #zig
klltkr has quit [Ping timeout: 265 seconds]
marnix has quit [Ping timeout: 260 seconds]
marnix has joined #zig
frmdstryr has quit [Quit: Konversation terminated!]
frmdstryr has joined #zig
FireFox317 has quit [Ping timeout: 246 seconds]
marnix has quit [Ping timeout: 258 seconds]
<Kena> Can a union be both tagged and packed?
<Kena> concurrently I mean.
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
radgeRayden has quit [Read error: Connection reset by peer]
wootehfoot has quit [Read error: Connection reset by peer]
<g-w1> did ziglang.org just switch to light theme?
<g-w1> or is my browser just being weird?
<andrewrk> still dark for me
<tane> I see white background with black text
Akuli has quit [Quit: Leaving]
<ugla> g-w1: Your browser might be saying that it prefers a light theme, for whatever reason. https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme
<travv0> ziglang.org has been light for me since i started using zig a couple weeks ago lol
<g-w1> thats what I thought, Im on a different pc than normal. thanks
<justin_smith> TIL google-chrome has a --force-dark-mode flag
<justin_smith> (I was wondering how to get that behavior without using a desktop environment)
skuzzymiglet has quit [Read error: No route to host]
tane has quit [Quit: Leaving]
skuzzymiglet has joined #zig
donniewest has quit [Quit: WeeChat 2.9]
<virkony> I think I'm doing something wrong. Have A catch return X; and now I want to lift catch to higher level. E.g. { try A; } catch return X; . Reason for this is to benefit from errdefer in C callback
<ifreund> virkony: yeah that's a bit of a pain point right now, this issue may interest you: https://github.com/ziglang/zig/issues/5610
mschwaig has quit [Ping timeout: 240 seconds]
mschwaig has joined #zig
skuzzymiglet has quit [Ping timeout: 260 seconds]
<virkony> thanks. that #1717 also looks interesting
<virkony> so basically current desugared version is struct { fn doit(...) !void { try A; } }.doit(...) catch return X
<virkony> with all control flow limits and stuff
Kena has quit [Remote host closed the connection]
<ifreund> honestly I'd just put the logic in toplevel helper function currently
CmdrCrisp has joined #zig
lemmi has quit [Ping timeout: 256 seconds]
yZ5vlALg86lP has joined #zig
<yZ5vlALg86lP> howdy all. what is the zig way of making an u16 out of a [2]u8?
<virkony> packing error for future unpack also makes sense to do aggregation
<justin_smith> yZ5vlALg86lP: bit-shift and bitwise and?
<virkony> yZ5vlALg86lP: shouldn't that depend on byte order you want to give to it?
<virkony> justin_smith: I guess or ;)
<justin_smith> virkony: right, my mistake
<yZ5vlALg86lP> the [2]u8 is of course network byte order
<justin_smith> virkony: at least with shift/ or you can just decide which of the two is msb explicitly, instead of checking / fighting endianness
<yZ5vlALg86lP> ok, so the classical way. there no ntoh giving it a buffer and getting an int.
<virkony> I would also expect compiler being able to figure out to just re-interpret memory and maybe apply byte swap :)
<justin_smith> yZ5vlALg86lP: that should also be possible with bitcast / pointercast or such, but I think the classic way is cleaner
<ifreund> yZ5vlALg86lP: mem.bytesAsValue()
<ifreund> or mem.readIntNative() or mem.reatIntForeign(), there are many options
<yZ5vlALg86lP> i like readVarInt() that can handle endiannes
<yZ5vlALg86lP> s
marler8997__ has joined #zig
marler8997_ has quit [Read error: Connection reset by peer]
<ifreund> that one is good if the number of bytes you're reading from doesn't perfectly match the type you want to store into
<ifreund> otherwise readIntLittle() or readIntBig() are a little nicer
<yZ5vlALg86lP> ah.
<virkony> Hmm... Having n+1 calls that can fail and I want to return first/last failure...
<virkony> does "if" create scope when used without block?.. if (X) defer Y; will defer Y till outer scope of "if"?...
* virkony just figured out that x.*.y can be written as x.y ...
<virkony> ifreund: I assume zig handles misaligned [2]u8 on platforms without CPU handling that
a92 has joined #zig