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]
<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
<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
<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>
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
<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 https://google.com/` 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 https://github.com/LewisGaul/zig-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