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 quit [Ping timeout: 260 seconds]
dbohdan has quit [Ping timeout: 256 seconds]
dbohdan has joined #zig
dominikh has joined #zig
<g-w1> is * a person on irc? I dont see them in the people on it?
<waleee-cl> sounds like something with your irc-client
* ifreund indeed i am
<ifreund> g-w1: * is /me
ur5us has joined #zig
skuzzymiglet has joined #zig
<dominikh> hey. I have this weird problem where the following trivial program hangs indefinitely instead of exiting: https://play.golang.org/p/jvGMvrobK1F – is this expected or a known issue? for a non-trivial program, it executes fine (including async/await), then hangs when it should exit. I couldn't find a fitting issue on github
skuzzymiglet has quit [Ping timeout: 256 seconds]
Kingsquee has joined #zig
<g-w1> try master branch (it works fine for me)
frmdstryr has quit [Ping timeout: 260 seconds]
a92 has quit [Quit: Leaving]
klltkr_ has quit [Ping timeout: 246 seconds]
<dominikh> well, master can't build it at all: https://play.golang.org/p/_twjR3zzsvE – and I'm not equipped to debug that
<waleee-cl> dominikh: is NetworkSubsystemFailed an error you have added?
<daurnimator> ifreund: I see I'm still winning the code golf ;)
<waleee-cl> bah. Why didn't grep find it in lib/std/os.zig
<dominikh> waleee-cl: the entirety of my code is this: https://play.golang.org/p/0p8ExGdjKMm – and all I'm doing is trying to build it with zig built from master
<waleee-cl> ah, change it to !void ?
<dominikh> same problem
<g-w1> it works fine for me https://i.imgur.com/exY9muX.png (this is pretty close to master)
<g-w1> yep
<g-w1> master doesn't work for me either, lol
<g-w1> its a regression: https://i.imgur.com/c0WmBlV.png
<g-w1> same error
klltkr has joined #zig
<ifreund> daurnimator: try brainfuck, it's a lot more fun :P
<ifreund> I'm losing that one now too though :(
<g-w1> it doesn't only seem to be files, that miminal example also doesn't work.
<g-w1> is the input from stdin in code.golf?
<dominikh> g-w1: fwiw, the hang doesn't occur with "almost master", so looks like that got fixed :)
<g-w1> yeah
<g-w1> ig now there is another issue tho :(
<dominikh> I'll live with 0.6 for now. I don't like async/await, anyway :P
<pixelherodev> code.golf looks like it might be fun
<g-w1> im trying the brainfuc, its actually pretty hard. i dont wanna use recursive descent/state machine because space.
<pixelherodev> I wonder how efficiently the full thing could be compressed for the beer one...
<pixelherodev> Probably not well enough
<daurnimator> pixelherodev: to 414 :)
<daurnimator> or at least that's what I got to
<andrewrk> is anyone able to reproduce https://github.com/ziglang/zig/issues/6830 locally?
<pixelherodev> daurnimator: you compressed the full string to 414?
<pixelherodev> Or you mean that's your winning size?
<pixelherodev> I think I might be able to get a working one under 400 without compression
<daurnimator> pixelherodev: that's the winning size; and I think I compressed pretty well
<pixelherodev> daurnimator, ifreund: dumb question, what'd you use to write to stdout? I was thinking of using write directly
<daurnimator> dunno how much I should give away from my solution
<pixelherodev> True :P
<pixelherodev> If only there was a std.debug.warn equivalent for stdout :(
<pixelherodev> s/warn/print/
<fengb> Add it in a PR :P
<pixelherodev> lol
<andrewrk> what you actually want is @import("std").fizzbuzz(); so I do not recognize this as a use case for std.debug.warn equivalent for stdout :)
<pixelherodev> lol
<pixelherodev> My "write to stdout" is nearly 100 chars right now *winces*
<pixelherodev> More than 100, actually. Ouch.
<pixelherodev> Maybe I should drop fmt.format usage...
<daurnimator> okay I'll tell you that my winning entry contains: `pub fn main()!void{const p=@import("std").io.getStdOut().writer().print;`
<pixelherodev> ... I totes forgot that exists :P
<pixelherodev> Thanks :P
<pixelherodev> I've used that in freestanding, how did I forget it exists??
<daurnimator> if anyone can make that shorter I'd be interested.....
<daurnimator> e.g. `io.File{.handle=1}.writer()` is a few characters longer
<waleee-cl> that was surpsingly J-ish (the simultaneous assignment & usage)
earnestly has quit [Ping timeout: 260 seconds]
<pixelherodev> oof
<daurnimator> waleee-cl: what was/is?
<waleee-cl> your stdout-main
<daurnimator> waleee-cl: huh?
<daurnimator> there is no usage there?
<waleee-cl> right. General look & feel similar to J then
<daurnimator> I don't see why it's similar to J....
<daurnimator> it's in most languages e.g. in javascript you could write `function main(){const p = require("something").foo().bar();`
kristoff_it2 has quit [Ping timeout: 256 seconds]
<pixelherodev> I can't compress the full text below ~800 bytes :(
<pixelherodev> That would've been a fun strategy
<g-w1> would var p be better, less text
<daurnimator> g-w1: `error: variable of type '(bound fn(std.io.writer.Writer(std.fs.file.File,std.os.WriteError,std.fs.file.File.write),[]const u8,anytype) anytype)' must be const or comptime`
<waleee-cl> (re J, the J scores on code.golf is disappointedly long it sems)
<g-w1> oh, that makes sense, cool. you just ruined my master plan :)
<waleee-cl> s/long/high/
<pixelherodev> With bzip, I can get it down to ~575 bytes, but that's still not adequate
<pixelherodev> Impressive (given input is >10KiB), but not good enough
<pixelherodev> (and bzip isn't supported by stdlib so it's more a thought experiment than anything else :P)
CmdrCrisp has quit [Ping timeout: 260 seconds]
ask6155 has joined #zig
<pixelherodev> Ugh, at 500 currently...
<pixelherodev> This does prove that manual compression into a Turing-complete language can exceed even the best "normal" compressors
<pixelherodev> New compressor idea: zz. A Zig-based compressor that compresses arbitrary text input into the shortest possible Zig program possible :P
<justin_smith> pixelherodev: this exists in the world of DSP, it's called generative compression https://arxiv.org/abs/1703.01467
ask6155 has left #zig [#zig]
<justin_smith> simplest possible version: turn a sine wave, unit amplitude, at 440 hz lasting 3 years, into a tuple {sin, 1, 440, 94608000}
<justin_smith> of course real usage won't use such a dumb special case generator
ask6155 has joined #zig
klltkr has quit [Ping timeout: 265 seconds]
<pixelherodev> Hmm. hmmmmm.
ask6155 has left #zig [#zig]
<justin_smith> pixelherodev: classic example might be a fractal generator, which could be said to contain ~infinite detail in a single formula (or even pi if you iterate down all the digits...)
xackus_ has joined #zig
xackus has quit [Ping timeout: 240 seconds]
<pixelherodev> ifreund: sorry! :)
<pixelherodev> Oh... oops.
<pixelherodev> I just spent at least an hour on it...
* pixelherodev facepalms
<pixelherodev> and daurnimator is still ahead of me by a bit! :P
lucid_0x80 has joined #zig
lucid_0x80 has quit [Ping timeout: 240 seconds]
ask6155 has joined #zig
<pixelherodev> daurnimator: I think I'm going to give up and let you keep first.
<pixelherodev> *eighteen freaking bytes* ugh
<pixelherodev> Ooh, I think I have it
ur5us has quit [Ping timeout: 260 seconds]
<daurnimator> pixelherodev: I'm curious to see your solution
<pixelherodev> daurnimator: same :)
<pixelherodev> Trade?
<daurnimator> as the winner I'm not sure if I should ;)
<pixelherodev> I promise not to use yours ;)
<pixelherodev> Note that I removed all newlines, hence the paste there is ~twelve bytes longer than the one shown on the site
<pixelherodev> s/shown/reported/
<pixelherodev> I tried embedding the one-case into the while loop but it ended up being worse; dittor for moving both "of beer"s into `e`
<daurnimator> pmed
<pixelherodev> Ohhhhhh
<pixelherodev> Smart :)
<pixelherodev> daurnimator: I see a way to improve yours further and beat it, but as promised I won't :P
<pixelherodev> I'll play with it locally to avoid it registering :)
<daurnimator> I really tried to get rid of the `comptime` but `[]const u8` is longer
* pixelherodev nods
osa1 has joined #zig
<pixelherodev> Yeah, that's a good point
<pixelherodev> Yours is definitely smarter, and I don't think I see any way to easily improve it...
ask6155 has left #zig [#zig]
<pixelherodev> daurnimator: figured out how to beat yours by one ;)
<pixelherodev> Still, thanks for that, I see what I was doing wrong now
<daurnimator> pixelherodev: oh? easy or hard change?
<pixelherodev> easy
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
<pixelherodev> Also, daurnimator, I found that []const u8 was smaller than comptime+inline whle
marnix has joined #zig
<pixelherodev> while*
<pixelherodev> Ah right, I;m using it a bit differently
<daurnimator> pixelherodev: note that without comptime you also need a type: `comptime var i=99` vs `var i:u8=99`
<pixelherodev> Yep
<pixelherodev> But again, I'm using a different hack which makes it up
<pixelherodev> Which doesn't work with comptime
<pixelherodev> Without switching to using comptime, I'm currently within seven of yours
<pixelherodev> And without another smart difference in yours
<pixelherodev> daurnimator: note that I'm reusing the []const u8 variable later :P
<pixelherodev> I *think* I could beat yours by ~10 if I wanted to, but not without using the info you gave me
<pixelherodev> I'm trying to find ways to beat it with *different* tricks entirely, but it's not fully making up the difference...
<pixelherodev> Ah well, I'll take the loss on this one, thanks for helping me waste two hours of my life :P
<daurnimator> I trimmed 3 chars off
lucid_0x80 has joined #zig
<pixelherodev> :)
<pixelherodev> Oof, I'm *one byte off* on the quine one
<pixelherodev> Ah wait, there it is
<pixelherodev> I'm guessing the quine one *can't* be improved...
moinstar has quit [Remote host closed the connection]
decentpenguin has quit [Ping timeout: 265 seconds]
<daurnimator> pixelherodev: likely
<daurnimator> made the 99 shorter again :)
tempnicksimp has quit [Ping timeout: 245 seconds]
decentpenguin has joined #zig
<daurnimator> and again
knebulae has quit [Ping timeout: 240 seconds]
nebulaek has joined #zig
decentpenguin has quit [Read error: Connection reset by peer]
knebulae has joined #zig
nebulaek has quit [Ping timeout: 240 seconds]
decentpenguin has joined #zig
mmohammadi9812 has quit [Ping timeout: 240 seconds]
mmohammadi9812 has joined #zig
frett27 has quit [Ping timeout: 246 seconds]
copy has joined #zig
copy has quit [Ping timeout: 260 seconds]
copy has joined #zig
lemmi has joined #zig
ask6155 has joined #zig
wesleyac has quit [Quit: ZNC 1.8.2 - https://znc.in]
wesleyac has joined #zig
mmohammadi9812 has quit [Ping timeout: 258 seconds]
mmohammadi9812 has joined #zig
ur5us has joined #zig
dumenci has joined #zig
lucid_0x80 has quit [Ping timeout: 265 seconds]
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
ask6155 has left #zig [#zig]
Kingsquee has quit []
earnestly has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
ur5us has joined #zig
cole-h has quit [Ping timeout: 260 seconds]
ur5us has quit [Ping timeout: 260 seconds]
rzezeski has quit [Quit: Connection closed for inactivity]
frett27 has joined #zig
FireFox317 has joined #zig
ask6155 has joined #zig
<ifreund> Ugh, I am also 1 byte off on quine
<daurnimator> quine cheat: the file name is code.zig
<ask6155> how do I use the -L flag? I have a folder with .h files and a folder with .so(s). In zig I get the error that it can't find `#include <x/x.h>` and I have put them in a seperate folder(for reasons). So how do I make zig find them?
<daurnimator> ask6155: -I
<ifreund> oh, I was using @src().file :D
<ifreund> there's the byte
<ask6155> daurnimator, ah that was it
FireFox317 has quit [Quit: Leaving]
<ask6155> I think this is unrelated but I'm getting an unrecognised glibc version error.
<ask6155> `unrecognised C ABI`
<ifreund> ask6155: are you using zig 0.6.0?
<ask6155> yes
<ask6155> latest release
<ifreund> your system glibc version is probably too new, this is an issue that has been fixed in master and won't be a problem with 0.7.0
<ask6155> I have 2.32-5
<ifreund> yeah, zig 0.6.0 only supports up to 2.31 iirc
<ifreund> there's some work around where you can manually specify the libc version but I forget the details
<ask6155> I tried using latest git version but I think it is broken due to the stage2 implementation
<ask6155> i mean the compiler
<daurnimator> -target native-native-gnu.2.31
<ifreund> ask6155: zig master works fine for me
<ask6155> is the zig binary in zig master the stage 2 compiler or the stage one?
<ifreund> it's still stage1
<ifreund> there is still a fair bit of C++, but more of the compiler was moved to zig recently
<ask6155> gnu.2.31 can't link to my lib.so (ldd can't find it)
<daurnimator> ask6155: what did you try?
<ask6155> zig build-exe file.zig -Iincludefolder -lc -llibx
<daurnimator> ask6155: add in `-target native-native-gnu.2.31` ?
<ifreund> iirc that didn't work
<ifreund> maybe using libc.txt would
<ask6155> I added that too. Then it said It can't find the library
<ask6155> also master branch requires llvm11 now. but it is not available in the repos yes
<ask6155> maybe I'll just wait for now
<daurnimator> ask6155: if it seems too hard; just download the nightly binary :)
<ask6155> ok I'll see about that
x2C25 has quit [Ping timeout: 260 seconds]
geert_ has joined #zig
skuzzymiglet has joined #zig
<ifreund> nice, got nix-shell working to let me compile zig using llvm11 binaries from nixpkgs while I wait for llvm11 on my distro
<ifreund> first time using nix, it's pretty nice
<dutchie> heh yeah, i did that exact thing to solve that exact problem :)
<dutchie> now if only i could figure out how to get nix to build zig binaries...
<dutchie> it was complaining that it couldn't write to $HOME/.cache, which makes sense because the nix sandbox won't let it
<dutchie> i tried setting XDG_CACHE_HOME to a directory in the build tree but then some weird stuff started happening
xackus_ has quit [Ping timeout: 246 seconds]
<dutchie> it seems to be importing builtin twice?
<dutchie> hmm, i can replicate with `XDG_CACHE_HOME=xdg_cache zig build`
rzezeski has joined #zig
<dutchie> i shall add a comment
<ifreund> nice
kristoff_it2 has joined #zig
nvmd has joined #zig
marnix has quit [Ping timeout: 240 seconds]
<ask6155> why doesn't arch have llvm11 by now?
marnix has joined #zig
<g-w1> iirc they are waiting on zig 0.7.0
<ask6155> it's in staging and hasn't gotten into extra (yet)
<ask6155> oof
<frett27> andrew is in personal troubles now, i think the 0.7 can wait a bit, as there are all elements on github / master
ask6155 has left #zig [#zig]
xackus_ has joined #zig
ask6155 has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
ask6155 has left #zig [#zig]
kristoff_it1 has joined #zig
kristoff_it2 has quit [Ping timeout: 260 seconds]
bgiannan has quit [Read error: Connection reset by peer]
WilhelmVonWeiner has quit [Ping timeout: 258 seconds]
nvmd has quit [Quit: Later nerds.]
<geert_> exit
<geert_> quit
<geert_> 
geert_ has quit [Quit: Lost terminal]
xackus_ has quit [Ping timeout: 256 seconds]
data-man has joined #zig
frmdstryr has joined #zig
donniewest has joined #zig
<data-man> ask6155: I use clang+llvm-11.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz in Arch, installed to /opt/llvm
<data-man> And cmake -DCMAKE_PREFIX_PATH=/opt/llvm -DZIG_PREFER_CLANG_CPP_DYLIB=OFF for building
data-man has quit [Quit: Konversation terminated!]
Kena has joined #zig
<ifreund> you can also just grab the arch package from staging
<Kena> Hello binary and digital people. Is the continue expression in a while loop evaluated after the expression in the loop? or it is before?
<earnestly> continue would necessarily have to be evaluated after the current loop iteration and before the next
<Kena> Thank you buddy.
moinstar has joined #zig
<Kena> I have a interrogation for a long time and still do not understand, what is the interest (or the use case) for compiling from source instead of using some pre-compiled binaries?
<pixelherodev> In what context?
<g-w1> maybe you don't trust the binary, or there is not a binary released for your platform, or you want cpu-specific optimisations
<pixelherodev> Or you want to disable specific features
<earnestly> A main reason is for different architectures and combinations of features which would require an exponential number of pre-compiled binaries. Another important reason is knowing if the binary you receive is actually the binary that would be produced from the source (reproducibility)
<Kena> I'm unable to answer that, I'm just trying to figure out why anyone would want to compile zig from source instead of merely downloading the pre-compiled binaries and use it as it is.
<pixelherodev> Ah, for Zig in particular
<earnestly> Someone has to also pre-compile binaries
<pixelherodev> Maybe you suspect a trusting trust attack :P
<Kena> lol
<earnestly> At least the problem has been countered
<Kena> Allright, thefore it is for security policy reasons.
<earnestly> Although not in zigs case because there's only one implementation
<pixelherodev> Kena: that's *one* reason
<pixelherodev> It depends on who's doing it
<pixelherodev> earnestly: I meant in the C++ compiler ;)
<earnestly> pixelherodev: Hm?
<pixelherodev> I'd say "a very smart trusting trust attack" but frankly it'd still be less complex than the compiler itself.
<earnestly> pixelherodev: Defeating the Trusting Trust problem requires multiple implementations
<Kena> Ah yes, missed the other replies, thanks guys :)
<earnestly> See Wheeler's thesis on Diverse Double Compiling
<pixelherodev> "Defeating" trusting trust requires going all the way back to the assembler.
<earnestly> No, see reference
<pixelherodev> I have.
<pixelherodev> But at a certain point you can start asking, "hey, if the *compiler* could be suspicious... what about the text editor? or assembler? or hex dumper?"
<pixelherodev> What if `sha256` is compromised and is lying when it says that the produced compilers match?
<pixelherodev> or `ls -l` was compromised to give the wrong length when a compiler was detected?
<earnestly> It's further a problem when you know proof doesn't compose
<earnestly> So you have to audit the entire system as a whole
<pixelherodev> The obvious answer is to use a system simple enough that you can inspect it with a logic probe ;)
<pixelherodev> e.g. a z80-based system. You can literally see what it's reading from memory - *if you can trust the logic probe* ;P
<earnestly> Or Wirth's Oberon heh
<pixelherodev> At a certain point, it's more an exercise in paranoia than a legitimate concern
<g-w1> is z80 used anymore? is it a mainframe os?
<pixelherodev> I use the z80 personally, and I'm working on designing a physical computer using one
<g-w1> you use it as a day to day os?
<pixelherodev> I was initially doing that as a hobby project for a game system, but now I genuinely want to use such a system for typical tasks (word processing, for instance)
<pixelherodev> g-w1: not *yet*, but hopefully within the next two years
xackus_ has joined #zig
<g-w1> nice
<earnestly> pixelherodev: Are you using zig with it currently?
<pixelherodev> Hahahahahaha, with a *z80*?
<earnestly> For it
<earnestly> (Does llvm even support it...)
<pixelherodev> I want to add a z80 backend to stage2 eventually, but I'm focusing on CBE for the 0.8 release
<pixelherodev> There was a revived patchset for LLVM-z80 support a few weeks back I think
<pixelherodev> There's a couple attempts going on, and at least a dozen abandoned ones ranging back over the past fifteen years.
<Kena> I hope you will succeed in your project.
dumenci has quit [Ping timeout: 256 seconds]
lucid_0x80 has joined #zig
<earnestly> Why you might want to build things yourself
skuzzymiglet has quit [Ping timeout: 240 seconds]
<Kena> Decidedly, you made my day, I will vote for you as the new chairman for noobies corporation.
<Kena> But maybe the guy's account suffered from social ingeneering to provide the community with false information, so logic probe fails here :D
<Kena> Or maybe the owner's account is legitimate but he secretly suffers from schizophrenia and even Ocaml or Coq can't beat it with their formal proof-driven theory.
Sergeeeek[m] has joined #zig
moinstar has quit [Quit: Leaving.]
frmdstryr has quit [Ping timeout: 260 seconds]
<Kena> It is desirable for a software to be written in order to compute the more possible informations at compilation time or is insane at a certain point?
<earnestly> The earlier you can find errors the better
<dutchie> also, normally you compile once and run often, so if you can compute things in the compile step you end up saving time overall
<earnestly> Stepanov often jokes about how programmers tend to compute the same thing repeatidly in their software
<earnestly> Even if it's trivial things like n / 1024 / 1024, which could be n / 1024 * 1024, which is then just n / 1048576. One less division. Or in other cases where a function computes some aspect of its input and then throws it away. E.g. printf usefully returns the number of bytes it wrote instead of discarding it
<pixelherodev> earnestly: except that those are optimized *anyways&
<pixelherodev> *
<pixelherodev> Not the printf example, that's definitely true
<pixelherodev> But anything involving basic arithmetic is downright trivial to optimize
<pixelherodev> I'd disagree with the idea that "as much as possible should be put in to compile time"
<pixelherodev> Some things are more expensive to compute at compile time than at run time by such a large margin that the time "saved" at runtime is so miniscule you'd have to run the program for millenia to make up for the cost incurred by a single compilation
<pixelherodev> I'd say that for *release* builds, as much as possible should be done at compile time, generally, since those are meant to be run for orders of magnitude more than they're compiled
<pixelherodev> But, since programmers spend most time (hopefully) in debug mode, that rule absolutely doesn't hold true - and the complexity needed to selectively build pieces at compile time is nowhere near worth the little bit it would gain
<pixelherodev> What's the old line, "programmer time is expensive, hardware is cheap?" Faster compilations = less programmer time = money saved. You're welcome ;)
<Kena> Thanks for the explanations, I always asked myself if the industry, even the embedded devices or internet of things, would benefit from software mostly computed at compile time.
dumenci has joined #zig
lucid_0x80 has quit [Ping timeout: 272 seconds]
Akuli has joined #zig
<earnestly> pixelherodev: His perspective is not about making assumptions of the compiler, obviously in that sort of context it doesn't make sense
<earnestly> pixelherodev: This is an example of the kind of thing he starts out with: https://0x0.st/ikWp.bin (c++ file)
<Kena> So time is more important than space I can conclude.
<earnestly> It depends
<pixelherodev> Depends on who you ask, what project you're working on, your priorities, etc
hnOsmium0001 has joined #zig
<g-w1> this code doesn't work. it says that it found a [13]Card instead of [52]Card. what am I doing wrong const deck_arr: [52]Card = [52]Card{ .two, .three, .four, .five, .six, .seven, .eight, .nine, .ten, .jack, .queen, .king, .ace, } ** 4;
<dutchie> the right hand side has 13 members
<g-w1> ah. i had to do this: const deck_arr: [52]Card = [13]Card{ .two, .three, .four, .five, .six, .seven, .eight, .nine, .ten, .jack, .queen, .king, .ace, } ** 4;
<dutchie> it parses as ([52]Card{ .two, .three, .four, .five, .six, .seven, .eight, .nine, .ten, .jack, .queen, .king, .ace, }) ** 4
<dutchie> you can just do [_]Card{ ... } to have the compiler count them for you
<g-w1> yeah
dumenci has quit [Quit: Leaving]
FireFox317 has joined #zig
xackus_ has quit [Ping timeout: 265 seconds]
skuzzymiglet has joined #zig
<johnLate> Where is defined what `zig build test-std` does? `git grep test-std` only finds CONTRIBUTING.md and a CI script...
<ifreund> in the build.zig
<ifreund> specifically addPkgTests() called with the name "std"
<g-w1> I think it is a seperate string that is combined
<g-w1> test_step.dependOn(tests.addPkgTests(b, test_filter, "lib/std/std.zig", "std", "Run the standard library tests", modes, false, skip_non_native, skip_libc, is_wine_enabled, is_qemu_enabled, is_wasmtime_enabled, glibc_multi_dir));
<johnLate> and this line basically includes all `test "…" { … }` sections from lib/std?
<johnLate> (I'm trying to figure out how to add a test for https://github.com/ziglang/zig/pull/6834 - see my last comment)
<g-w1> im pretty sure that is true. in std.zig:94 you will find the thing that does all the magic.
osa1 has quit [Remote host closed the connection]
frmdstryr has joined #zig
geert_ has joined #zig
<pixelherodev> Or at least *most* of the magic :)
<g-w1> where is the rest of the magic?
<geert_> Following the Zig language for awhile and made some important tools with it. The question is how could I contribute with coding and docs? Just ask on an issue on Github or is their a better way?
jicksaw has quit [Quit: ZNC is kill]
<g-w1> I got started by looking at some of the issues on github with the contibutor friendly tag and then trying to solve them. I found the ones relatting to main.zig to be the easiest, probably because it has bugs because it is pretty new. this one looks fairly easy if you are farmilar with tokenizers: https://github.com/ziglang/zig/issues/6823.
<geert_> thanks
<g-w1> I have only made 2 prs and working on 3rd so I am not expert by any means
<geert_> Just fix them and not ask to fix them in the comments?
<g-w1> yeah!
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
<johnLate> Is there any difference between "!void" and "anyerror!void"?
xackus_ has joined #zig
FireFox317 has quit [Quit: Leaving]
<andrewrk> the former error set is inferred; the latter is the global error set
CmdrCrisp has joined #zig
<Kena> the inferred one does NOT benefit from additionaly optimizations right?
<andrewrk> in theory it's possible, in practice not likely. the main purpose of inferred error sets is to help you, the programmer, cover all the edge cases
<companion_cube> imho, type inference should *never* change the underlying behavior
jicksaw has joined #zig
<companion_cube> (i.e. a fully annotated program is the same as the program with some types inferred)
<Kena> That reminds me, one principle of Python or D (don't recall): explicit is better than implicit.
<companion_cube> always thought it was rich that python had that in its zen
<Kena> Please does the `|_|`represent a anonymous payload?
<companion_cube> _ just means to ignore a value
tane has joined #zig
<andrewrk> companion_cube, type inference could potentially provide more information to the optimizer, is all
<Kena> But when |_| is associated with a for loop, you can't ignore it. I'm speaking about the Labeled for example in the doc (see: https://ziglang.org/documentation/master/#Labeled-for)
<Kena> It's just a captured value (or payload) without an name, is that right?
<companion_cube> andrewrk: ah, if the type inferred is smaller than anyerror? yeah
<companion_cube> but then it should still be the same as writing the exact error set
<travv0> is the logic behind not having compiler warnings that something is either fine to do or it's forbidden? i remember seeing andrewrk say in an issue that no warnings is deliberate and was wondering if there was more info somewhere on the decision
<companion_cube> (the LSP should be able to suggest the exact error set, ideally)
<justin_smith> Kena: in other languages _ is a valid identifier, and by convention it's used for values you need to exist but don't actually touch
<travv0> cause i've been bitten by stuff like forgetting to use an argument or something in a function before and wished there was a warning about it
<companion_cube> afaik in all languages that have destructuring/pattern matching, _ is the wildcard
<justin_smith> companion_cube: but it's used when you aren't interested in binding the value in that position, right?
<companion_cube> yes
<companion_cube> matches anything, discards the value
<Kena> But it is interesting for the compiler? I mean does `|_|` allow to allocate a smaller memory space for the payload than it would do with `|value|` syntax? In a for or while loop context I mean.
<justin_smith> Kena: the compiler shouldn't warn / error if you rebind _
<Kena> Allright, thank you.
<justin_smith> usually shadowing does error
<justin_smith> Kena: I guess hypothetically you could save stack space if you know you aren't using a block local?
CmdrCrisp has quit [Ping timeout: 260 seconds]
<Kena> Yes, I beginning to grasp some wisdom shards along the way. I hope there will be more memory management-related informations in the docs during the upcoming release.
<Kena> It's cleary the kind of mechanics that it seduces me and push me into the low-level language segment.
<justin_smith> I would if that would be saving the space of a full copy of the object, or just a pointer?
<Kena> a pointer! :D
frett27_ has joined #zig
<companion_cube> I imagine it's just like ignoring the result of some expression
<companion_cube> the compiler is free to not store it
frett27 has quit [Ping timeout: 240 seconds]
xackus_ has quit [Ping timeout: 260 seconds]
skuzzymiglet has quit [Ping timeout: 264 seconds]
skuzzymiglet has joined #zig
Patrice_ has joined #zig
geert_ has quit [Ping timeout: 256 seconds]
frett27_ has quit [Ping timeout: 265 seconds]
Kingsquee has joined #zig
cole-h has joined #zig
xackus_ has joined #zig
riba has joined #zig
<Kena> Please do you know about an article that explain how does a compiler work? like the lexical analysis, the parsing, the analysis semantic, code generation and linking. It could help a noob like me to better understand how zig deals about memory.
<earnestly> Kena: Look up the Dragon Book
<g-w1> Kena: honestly, the self hosted compiler is a very good example for the frontend of the compiler. Right now I am writing a compiler to learn, and I kinda just winged it for the semantic anlysis and codegen. the llvm tuturial is also pretty good. here are some resources I found useful when writing my compiler https://github.com/g-w1/ezc#resources .I hope this helps you!
<Kena> Thanks, do you think "Compilers: Principles, Techniques, and Tools" from Dragon book published in 2006 is nevertheless better than the most recent ones from other publishers?
<g-w1> I havent read but have heard that it is kinda dated. https://teachyourselfcs.com/#languages
<Kena> thanks g-w1 that's very kind.
riba has quit [Ping timeout: 260 seconds]
riba has joined #zig
x2C25 has joined #zig
mmohammadi9812 has quit [Read error: Connection reset by peer]
mmohammadi9812 has joined #zig
tane has quit [Ping timeout: 256 seconds]
geert_ has joined #zig
ur5us has joined #zig
CmdrCrisp has joined #zig
CmdrCrisp has quit [Ping timeout: 260 seconds]
tane has joined #zig
mgxm has quit [*.net *.split]
tracernz has quit [*.net *.split]
mgxm has joined #zig
tracernz has joined #zig
<g-w1> I am getting a compile time error because an inline for exceeds 1000 branches, what can I do to fix this. is there a @builtin to help?
donniewest has quit [Ping timeout: 260 seconds]
Kena has quit [Remote host closed the connection]
riba has quit [Ping timeout: 246 seconds]
marnix has quit [Ping timeout: 240 seconds]
<frmdstryr> ldd warning firmware.elf.o:(.ARM.attributes): unknown THUMB_ISA_use value: 3
<frmdstryr> lld uses blx instruction, no object with architecture supporting feature detected
<frmdstryr> Anyone have any info on what that means / how to fix it?
<frmdstryr> It's an stm32l5 (cortex-m33)
<justin_smith> I'm trying to use a slice with an API that takes a "user data" void pointer
<g-w1> slice.ptr
<justin_smith> I'm able to use @ptrCast to make a *c_void from the slice, but how do I get the slice back from the void?
<justin_smith> I can only provide one arg, I'd like to pass the slice so that I know the count when I get it back
<justin_smith> or do I need a sentinal null?
mmohammadi9812 has quit [Remote host closed the connection]
mmohammadi9812 has joined #zig
skuzzymiglet has quit [Remote host closed the connection]
<justin_smith> g-w1: that gets the pointer, but loses the length info, what I really want is to round trip the slice itself
<g-w1> does the length change after you pass it to the api
<justin_smith> never
<justin_smith> all it does to my void pointer is pass it back to my callback
<g-w1> so why dont you just pass the pointer and keep the length with ptr.len
skuzzymiglet has joined #zig
<justin_smith> g-w1: because my callback only gets the data from the API
skuzzymiglet has quit [Client Quit]
skuzzymiglet has joined #zig
<justin_smith> g-w1: I can't "keep" anything, I register a handling function and a void pointer, that function is called later with that pointer as an arg
<g-w1> ohh. If this were me I would make an array with [len, ...rest of elements] and then pass that.
<g-w1> so you know the first element is the len
skuzzymiglet has quit [Client Quit]
<justin_smith> g-w1: I was trying to use a slice for this, because I thought that was what a slice was
<g-w1> ok
<justin_smith> but I couldn't get the conversion from void back to slice, and maybe that's the wrong way to do this
skuzzymiglet has joined #zig
<tane> justin_smith, take a pointer to slice, cast it to *c_void, then cast that back to pointer to slice
<g-w1> there should be a way.
<justin_smith> tane: OK, I thought I was doing that, clearly I'm doing something else stupid
<tane> what is the preferred paste service herE?
mmohammadi9812 has quit [Quit: Quit]
<g-w1> I don't know if there is one
<tane> maybe something along these lines will work
<justin_smith> tane: thanks, that looks helpful
skuzzymiglet has quit [Client Quit]
skuzzymiglet has joined #zig
mmohammadi9812 has joined #zig
CmdrCrisp has joined #zig
mmohammadi9812 has quit [Client Quit]
skuzzymiglet has quit [Client Quit]
skuzzymiglet has joined #zig
mmohammadi9812 has joined #zig
xackus_ has quit [Ping timeout: 256 seconds]
tane has quit [Quit: Leaving]
Akuli has quit [Quit: Leaving]
frmdstryr has quit [Ping timeout: 260 seconds]
<andrewrk> this issue #6830 is such a thorn in my side right now
skuzzymiglet has quit [Ping timeout: 260 seconds]
frmdstryr has joined #zig
<ifreund> that's certainly a weird one :(
frmdstryr has quit [Quit: Konversation terminated!]
frmdstryr has joined #zig
a92 has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
mmohammadi9812 has quit [Ping timeout: 260 seconds]
geert_ has quit [Ping timeout: 258 seconds]
<rom1504> can you ssh to this azure devops CI ?
ur5us has joined #zig
<andrewrk> no
<andrewrk> you can repro it on a macos computer though
<rom1504> I found https://github.com/marketplace/actions/debugging-with-tmate very convenient to debug with github action (which supports linux, windows and macos!)
<rom1504> might be interesting to try github action
<rom1504> the azure devops yaml you have looks surprisingly similar to github action yaml, that's interesting
<rom1504> but anyway for sure if you can reproduce locally it's easier and better
someguestguy has joined #zig
<someguestguy> so If I'm trying to print the name of a given enum value like this
<someguestguy> @tagName(@intToEnum(qs_msgs, queue_status >> 16))
<someguestguy> you end up with undefined behavior if your input value isn't part of an non-exhaustive enum
<someguestguy> I want to do a if-check to either print the tag name or not if the tag is present, but I can't really just return "no tag name" but I don't know how to use the builtins (typeof, typeinfo, etc) to check.
<someguestguy> error messages aren't helping a lot on how to access the members (printing @typeInfo(@typeof()) confused me.
<someguestguy> basically how do I get @tagName to not invoke undefined behavior, or fi
<someguestguy> if-check*
<someguestguy> for whether it's available then either call @tagName or not.
<someguestguy> (nevermind, someone pointed me to the std.meta versions where it doesn't panic and instead returns an error)
someguestguy has quit [Remote host closed the connection]