ChanServ changed the topic of #zig to: zig programming language | | be excellent to each other | channel logs:
kbd has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
casaca has joined #zig
<marler8997> yeah I was half joking he would do that, but also half expecting him to :)
supercoven has quit [Ping timeout: 276 seconds]
kbd has joined #zig
ed_t has quit [Quit: Leaving]
nvmd has quit [Quit: Later nerds.]
nvmd has joined #zig
<daurnimator> > /// Returns true if the key was already present.
<daurnimator> ^ liar
<daurnimator> :P
squeek502 has quit [Remote host closed the connection]
squeek502 has joined #zig
xackus_ has quit [Ping timeout: 265 seconds]
kbd has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
kbd has joined #zig
kbd has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
craigo has quit [Ping timeout: 276 seconds]
cole-h has joined #zig
nvmd has quit [Quit: Later nerds.]
geemili has quit [Quit: WeeChat 2.8]
leroycep has joined #zig
kbd has joined #zig
<marler8997> I must say, I like how clever our buildpkgs solution is, however, when I think about how long it takes to explain it to people and compare that with @tryImport I'm less enchanted
notzmv has quit [Ping timeout: 240 seconds]
kbd has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
kbd has joined #zig
Techcable has quit [Remote host closed the connection]
waleee-cl has quit [Quit: Connection closed for inactivity]
kbd has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
earnestly has quit [Ping timeout: 264 seconds]
jokoon has joined #zig
cole-h has quit [Ping timeout: 264 seconds]
bitmapper has quit [Quit: Connection closed for inactivity]
<marler8997> g-w1, I got ziget to compile OpenSSL statically from source!
<marler8997> took a couple hours to get the build.zig file together to get just the right set of source files
<marler8997> compiling openssl statically does make the ziget binary go from about 800 KB to 9 MB :)
midgard_ has quit [Ping timeout: 240 seconds]
jokoon has quit [Ping timeout: 272 seconds]
leon-p has joined #zig
jokoon has joined #zig
earnestly has joined #zig
midgard has joined #zig
jokoon has quit [Quit: Leaving]
<andrewrk> mikdusan, I got llvm12 branch up to speed with CPU features of all targets except for arm and aarch64 left to do. I still get that asm error though
<andrewrk> `./zig build-exe ../test/standalone/hello_world/hello.zig --verbose-llvm-cpu-features` reveals that we are incorrectly passing i386-unknown-linux-gnu to llvm for building compiler-rt
<andrewrk> in master branch we correctly pass x86_64-unknown-linux-gnu
<andrewrk> target.cpp is missing corresponding changes to the enum
<andrewrk> hmm nope, spoke too soon
<andrewrk> lib/std/target.zig was missing powerpcle
ncon has quit [Remote host closed the connection]
ncon1 has joined #zig
<andrewrk> ok we're in much better shape now. I just need to finish upgrading cpu features for arm and aarch64 and then we'll be ready to run the test suite and find regressions
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
ncon1 has quit [Quit: Quit Goodbye!]
ncon has joined #zig
podge has joined #zig
podge has quit [Ping timeout: 264 seconds]
podge has joined #zig
braket has quit [Ping timeout: 260 seconds]
<mmurd> just ran into this working on some stuff with childprocess, not sure how to work around but figured this was my first stop :)
<mmurd> ah, evented io is the cause. Unfortunately the whole program is currently built around that…
jokoon has joined #zig
cren has joined #zig
<cren> hey, how do I check if a variable is `undefined`? or if I can't, what should I be doing instead?
<ifreund> cren: you can't, undefined means that the variable could have literally any value
<ifreund> you probably want to use an optional type
<ifreund> mmurd: if you don't care about portability you could probably just fork/execve or whatever your OS does
jokoon has quit [Quit: Leaving]
kbd has joined #zig
<mmurd> ifreund, I'm hacking on rundird, do I care about portability? :D I had assumed not and am trying fork/execveZ (based on code in river)
<ifreund> mmurd: currently rundird uses prctl so it's already linux specific. fork/execeve are fine
leon-p has quit [Ping timeout: 240 seconds]
leon-p has joined #zig
kbd has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
<mmurd> I'm getting '[*:0]const u8', found '[]u8' when passing the return of fs.path.join to os.execveZ, is a ptrCast the way to go or something else?
bitmapper has joined #zig
<ifreund> you need a null terminated pointer, a []u8 is not gaurenteed to be null terminated
<ifreund> s/null/0/
craigo has joined #zig
karchnu has quit [Ping timeout: 256 seconds]
<mmurd> ifreund, how can I create a null terminated pointer from a []u8?
<ifreund> std.mem.Allocator.dupeZ()
<mmurd> Thanks! :)
<ifreund> marler8997: was just looking at the readme of stitch again. I'm not a huge fan of the fact that variables are prefixed with the same symbol ($) as keywords when referencing them. IMO it would be nice to use a different symbol to distinguish them from keywords
<marler8997> there currently are no keywords
<ifreund> perhaps keywords are the wrong name, I think I mean builtins like $echo
<marler8997> these keywords are actually just variables as well
<marler8997> $echo is a variable that returns a Builtin object
<ifreund> hmm, I see
<ifreund> I think I'd prefer @echo or similar for builtins for readability
<marler8997> so you'd like to namespace different types of variables with a different symbol
<marler8997> @foo vs $foo (@foo is a builtin, $foo is a variable)
<ifreund> can users redefine bulitins or create their own/
<marler8997> a builtin is just like any other program
<marler8997> right now you can do this: $call myotherscript ...
<marler8997> and maybe I could support this: $set myotherscript $load myotherscript
<marler8997> then, $myotherscript would call that script
<ifreund> ok so builtins are currently just a small collection of simple programs defined by the spec?
<marler8997> yes
<marler8997> everything is program, no functions (haven't found a need for them yet)
<ifreund> so the value stored in $echo is what, the path to the echo executable?
<marler8997> of course, the builtin programs are just implemented as internal functions in the interpreter, but from the perspective of a stitch script they behave exactly the same
<marler8997> $echo is a Builtin object
<marler8997> there's a handful of Object type in stitch so far
<marler8997> String, Bool, Builtin, CommandResult
<marler8997> you're giving me ideas on how to better document this :)
<ifreund> ah so not everything is text, that's probably good
<marler8997> I started with everything being text
<marler8997> as I went on I found that adding a few types made a few things alot simpler
<ifreund> does '$set echo foo' work?
<marler8997> yes
<marler8997> however
<marler8997> $echo still points to the builtin
<marler8997> there is a special scope that allows you to set/retreive user-defined symbols that conflict with reserved symbols
<marler8997> right now it's "g" for "global", so $g.echo
<ifreund> would you need that if builtins used @echo insted of $echo? are there other resereved symbols?
<marler8997> yes, like $scriptfile
<marler8997> I could make that a program though
<marler8997> you'd have to call it like (@scriptfile)
<marler8997> that is an interesting idea
<ifreund> I think that would be a reasonable tradeoff tbh
<marler8997> make @ be for all reserved things
<marler8997> and $ for user-defined things
<ifreund> I strongly feel that using @ for reserved things makes the code more readable
<marler8997> you might be right
<marler8997> if that's the case then I will probably use it
<marler8997> I've started by limiting myself to only a few reserved characters, currently there are only 4: $, #, ( and )
<marler8997> keeping them limited is good, but not if it sacrifices too much readability
<ifreund> hmm, would $@"foo" become @@"foo" ?
<marler8997> $@ would be a syntax error
<marler8997> dollar doesn't recognize and @ symbol for anything
<marler8997> oh wait hold on
<marler8997> sorry
<marler8997> I forgot
<marler8997> that's a delimited string literal
<marler8997> I need to change the name of that
<marler8997> could go either way, either $@"foo" or @@"foo"
<ifreund> could also do @$"foo"
<marler8997> I've also considered shorthand, $"foo", which would also mean @"foo"
<marler8997> and "foo" is still on the table
<marler8997> this mean making double-quote a special character
<ifreund> plain "foo" sounds like more language complexity for questionable value
<ifreund> I think @"foo" is ergonomic enough
<marler8997> ok I'll remember that
<marler8997> I'm updating my docs based on our conversation as we speak
<ifreund> cool :)
<g-w1> marler8997: nice, how long does it take to build, and did you get it with zigup yet?
<marler8997> I could use @"foo" for the shorthand, $@|delimited| for the delimited
<marler8997> I think that makes intuitive sense
<marler8997> g-w1, try it out for yourself :) haven't tried it with zigup yet
eax has joined #zig
<g-w1> ok cool
<marler8997> takes 7.4 seconds on my machine
<marler8997> but my machine is pretty baller :)
<ifreund> marler8997: isn't $@ leaking a builtin type thing into the non-reserved namespace? @$|delimited| would make more sense IMO
<marler8997> ah, that's true
<g-w1> how do I get static openssl? it wants to use system openssl rn with -Dopenssl
<marler8997> -Dopensslstatic of course :)
<marler8997> the build code for either actually has no shared code, but the zig module is exactly the same for both
<g-w1> ah, nice
<g-w1> did you push? its not showing up for me
<marler8997> it's a PR
<g-w1> ah
<g-w1> nice the c is compiling in tandem
<g-w1> hmm, doesn't work for me
<marler8997> might need to check openssl/ssl.zig to see if the error reporting is accurate, I'm no openssl expert :)
<g-w1> ok
<marler8997> ifreund, I'm making the change to @ for reserved. I like it
<g-w1> seems legit
<marler8997> right, but I'm not sure error code 5 is the info we need
<g-w1> oh, you mean figure out what 5 means
n0tekky has joined #zig
<marler8997> and/or, if the error is getting retrieved correctly
<g-w1> ok, I put a tagname in there
<g-w1> oh, its not an enum
<marler8997> I'm saying I may not be calling the right function to get the error, or calling it the right way
<g-w1> will debug more later
<ifreund> marler8997: cool, I think it will be a net positive for cognative load despite bringing stitch up to 5 special symbols :)
<marler8997> yeah I agree, after I played with it on some code it was more readable and I think it helps to immediately see whether a symbol is defined by the language or the user
<ifreund> yeah I think making that distinction instantly clear will make learning the language much easier when one does not yet have all the builtins memorized
cole-h has joined #zig
falseblah has quit [Ping timeout: 256 seconds]
<cren> how do I stringify something in Zig? like Python's __str__() or Java's toString()
n0tekky has quit [Quit: Leaving]
<g-w1> std.fmt.format
<g-w1> you probably want to define a format function though
skuzzymiglet has quit [Quit: WeeChat 3.0.1]
braket has joined #zig
skuzzymiglet has joined #zig
dyeplexer has joined #zig
waleee-cl has joined #zig
<cren> what's the `writer` argument for std.fmt.format for? it doesn't seem to be explained in the documenting comment
<Nypsie> The result will be written to the given `writer`
<cren> ahh
<cren> yeah I just realised it returns `void` and not []u8
<Nypsie> There's std.fmt.allocPrint if you just need the slice of bytes
hidayat has joined #zig
<hidayat> Maybe this something that is already discussed but I did not
<hidayat> see any topics on it on github.
<hidayat> I have some concerns about namespaces and aliasing in Zig.
<hidayat> Titus Winters brings up some of these concerns in C++:
<hidayat> In C, you don't have namespaces so this problem does not exist in C.
<hidayat> The problem in C++ is that you can include namespaces in the current scope and that they can be nested.
<hidayat> For example:
<hidayat> using std::filesystem::open;
<hidayat> .... (100 lines of code down)
<hidayat> open(name);
<hidayat> Because someone has hidden std::filesystem, you lose context when reading the open function.
<hidayat> You also lose readability and it makes it harder to search for the name in a large project.
<hidayat> Searching for open will probably give a lot false positive, searching for std::filesystem::open
<hidayat> is going to be more unique.
<hidayat> In Zig we have even more problems, first it has usingnamespace, so it will have the same problems as C++.
<hidayat> You can have best practices to not use usingnamespace, but in Zig you choose the namespace name yourself,
<hidayat> so you need best practices to use the same namespace or have well-explained function names.
<hidayat> Zig also has aliasing for functions, this adds more problems, Let's say we have a function
ifreund has quit [Ping timeout: 260 seconds]
<hidayat> I dont know why I got spaces between each line:)
<hidayat> I dont know why I got spaces between each row:)
ifreund has joined #zig
<mikdusan> hidayat: except in zig is anti-shadowing. In c++ the using stuff becomes one big fat searchlist with neverending headache
<hidayat> as long as you are not expecting someone to write a specific namespace to get more context, I guess you are fine, But being able to alias functions could be a problem in large projects
<hidayat> python has the same functionality, but python is usually used for small project, If zig was used for example in something like unreal engine, you do not want to allow people to alias functions
<mikdusan> that's a long video. any hint at where Titus concentrates on fn aliasing?
<hidayat> starts around 22 min
<hidayat> not aliasing, but namespaces
<cren> oh, my data are actually all ?u32, so I could use std.fmt.formatInt() perhaps
<cren> oh that one still needs a `writer`
<cren> what I really want is just to convert integers to strings
Akuli has joined #zig
<v0idify> is zig's async system similar to the coroutines described under "knuth's coroutines" here?
<cren> (I'm using bufPrint now, seems to be what I want)
<mikdusan> andrewrk: fyi looking into -target x86_64-windows-msvc segfault. it's somehow ending up with bogus llvm-ir:
<mikdusan> target triple = "x86_64-unknown-windows-msvc"
<mikdusan> CORRECTION: target triple = "x86_64-unknown-windows-musleabihf"
<mikdusan> on llvm12 branch
riba has joined #zig
<mikdusan> oh enum is 1-off from msvc. probably a list sync issue
Techcable has joined #zig
riba has quit [Ping timeout: 276 seconds]
riba has joined #zig
dyeplexer has quit [Remote host closed the connection]
Techcable__ has joined #zig
Techcable has quit [Remote host closed the connection]
Techcable__ has quit [Remote host closed the connection]
Techcable has joined #zig
riba has quit [Ping timeout: 265 seconds]
<mikdusan> rolled a test-fix into same PR
<mikdusan> yay. llvm12 branch w/ PR just passed `zig build test -Dskip-release -Dskip-non-native`
<cren> is it possible to check if an optional pointer is a null reference in the condition of a while loop?
factormystic has joined #zig
<Nypsie> While loops allow for captures like so: `while(optional)|capture| {}
<Nypsie> if that's what you mean
<cren> that's the sort of thing, yes
<cren> what I need is for iteration to stop when head_p.*.next is no longer a valid pointer
<cren> (that is, when it's null)
<Nypsie> You should be able to simply do btw, no need to dereference it first
<Nypsie> Also, Zig has optionals. Pointers cannot be assigned `null` unless it's an optional
<cren> oh, that's handy
<Nypsie> In which case you can do:
<cren> Yeah head_p.*.next is a ?*Node
<cren> (Node's a struct)
<Nypsie> Ah ok, gotcha
<Nypsie> Then you could do something like this:
<Nypsie> `var current =;
<Nypsie> `while(current)|next| : { current = }`
<cren> oh, what's that colon for?
* cren looks up while loops in the docs quickly
<cren> is it an empty continue-expression?
<Nypsie> There's some example in the LinkedList source code:
<cren> ah thanks! did you guess that what I'm trying to do is implement a linked list?
<Nypsie> For while loops with optionals, you can find the refernce here:
<Nypsie> cren: That's what I figured with the naming you gave it :P
<cren> thought that might have given it away :)
hidayat has quit [Quit: Connection closed]
<andrewrk> oops sorry for the broken master branch
<andrewrk> thanks mikdusan
<andrewrk> I cherry picked your translate-c test case fix into master too
podge has quit [Ping timeout: 264 seconds]
hnOsmium0001 has joined #zig
<mikdusan> btw has zig lang-spec taken a position on not-strictly-needed escapes "\'" and '\"' in string literals?
emptee has joined #zig
<mikdusan> actually I'll put the question in discord for our resident spec guy :)
eax has quit [Ping timeout: 268 seconds]
kbd has joined #zig
a_chou has joined #zig
kbd has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
<mikdusan> ah nice. llvm2 success on macos: `zig build test -Dskip-non-native` (debug and release modes passed)
<andrewrk> x86?
a_chou has quit [Remote host closed the connection]
<mikdusan> yes. I'm holding out for iMac w/ arm64 :P
<andrewrk> if you're looking for a way to help, there is a big hairy issue to resolve
<mikdusan> if i can sure
<andrewrk> I believe we are triggering an llvm assert, even with version 11, in master branch
<andrewrk> I have not taken the time to attack the issue head on
<andrewrk> but ideally we would be assertion-clean after upgrading llvm versions
<mikdusan> does it trigger on x86?
<andrewrk> I believe so
<andrewrk> but you have to use a debug build of llvm (clang and lld can still be release mode)
<mikdusan> ok so a debug llvm + debug zig, and `zig build test` and I should hit it?
<andrewrk> yes
<mikdusan> will give it a shot
<andrewrk> I think I made an issue for it? let me check
<andrewrk> mikdusan, yep, found it:
<andrewrk> there's an even simpler repro for you thereo
Akuli has quit [Quit: Leaving]
<mikdusan> awesome
<andrewrk> hmm maybe this is an llvm bug?
<g-w1> oh, so that sret bug was the thing also preventing zig1 from building?
<andrewrk> looks like FireFox317 found UB in llvm's dwarf code
<mikdusan> g-w1 yup sret manifested twice for us :)
LewisGaul has joined #zig
<g-w1> ok
<andrewrk> llvm12 checklist now looks like: 1. finish CPU features script for arm and aarch64, 2. run full test suite with llvm assertions enabled, cross fingers
<mikdusan> so close. btw tried your update_cpu_features script. awesomeness.
<LewisGaul> Hey everyone, new here :)
<g-w1> LewisGaul: hi!
<marler8997> g-w1, zigup working with opensslstatic, just pushed to master
<andrewrk> welcome LewisGaul!
<andrewrk> marler8997, nice does that make it work on windows now too?
<g-w1> nice, it fails on `ziget` for me. does this happen for you?
<marler8997> andrewrk, I have to call the openssl config and make file to generate a few files, so will need perl and make and so on at the moment for windows
<marler8997> g-w1, it works for me so we'll have to figure out what's going wrong with yours
<g-w1> what os?
<marler8997> NixOS
<g-w1> im on nixos, tried on 2 machines
<LewisGaul> I've been watching your streams on vimeo recently andrewrk thought I should come along and say hi, also keen to get involved
<marler8997> I should try on a few other machines and see if it works
<andrewrk> LewisGaul, looking forward to working with you :)
<LewisGaul> Thought I'd have a go at writing a parser for NestedText, may have some slightly noobish questions along the way - not sure if this is a suitable place for them or I should prefer discord?
<g-w1> here is fine, discord works also
<LewisGaul> ok cools :)
emptee has quit [Remote host closed the connection]
emptee has joined #zig
<g-w1> hmm, google doesn't work, but zigup works with opensslstatic
<g-w1> also it breaks when trying static musl
<g-w1> after that, we can do a curl based install script :D
<marler8997> yeah I had started one, but then stopped because I realized we would need a static exe for that
<marler8997> andrewrk, I noticed that you can't set a sub-sub package with the same name to different modules, is this an intentional restriction or an oversight?
<andrewrk> if I understand correctly it is an oversight
<andrewrk> each package should have an independent package name table
<marler8997> and they can have different entries for package of the same name correct?
<andrewrk> yes, e.g. package a can @import("c") and package b can @import("c") and get completely different results
<marler8997> ok that makes sense then
<andrewrk> not sure where the bug is there; seems like we set up things to make this work
<andrewrk> probably something silly
<g-w1> marler8997: i only get this when linking musl??
<marler8997> what -Dtarget=??
<marler8997> should be *openssl.FILE, now I can build with x86_64-linux-musl
<marler8997> that's pretty cool Zig was able to find that bug :)
<marler8997> I've pushed the fix to master, update and try again
<g-w1> k
ifreund has quit [Ping timeout: 264 seconds]
<g-w1> yep, i think you just need to update the ziget_repo in build.zig sha
ifreund has joined #zig
riba has joined #zig
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
isolier has quit [Quit: Ping timeout (120 seconds)]
isolier has joined #zig
riba has quit [Ping timeout: 276 seconds]
emptee has quit [Quit: Konversation terminated!]