<ceymard>
are promise part of async / await ? they're undocumented as of now ?
<mq32>
ceymard, async values are promises
<mq32>
var x = async foo();
<mq32>
x is a promise that can be awaited with "var x_unpacked = await x"
<daurnimator>
andrewrk: seems like ZIG_SKIP_INSTALL_LIB_FILES is required if `make` doesn't have write priveledges to the final location.... which is super odd. `make; sudo make install` is a pretty class flow...
<daurnimator>
in any case, I'm now running the full test suite after just a `make`. now heading to bed.
<kenaryn>
Please, doess llvm-9.0.0.src need to be located in '~/local' before running 'cmake' command with prefix=$HOME/local?
<kenaryn>
Thanks TheLemonMan but now I have to add the unverified signature of the apt.llvm.org to a trusted vault. But gpg fails to add a new key. It tells 'no keyserver available' when I try to connect to gpgkeys.mit.edu. My /etc/resolv.conf contains only 1 line: 'name 192.168.0.1', is that normal?
<kenaryn>
gpg -a --export <PUB_KEY> | apt-key add -
<kenaryn>
For from now, it doesn't work anymore. I tried also to install Zig with snap but did'nt work and corrupted several apparmor profiles (which cannot be de-activated since the snap files doesn't exist anymore)
<kenaryn>
Is that normal my /etc/network/interfaces contains only:
<kenaryn>
auto lo
<kenaryn>
iface lo inet loopback
<kenaryn>
?
<kenaryn>
It is quite discouraging and painfully to install zig and begining to learn... :(
<mq32>
kenaryn, why that?
<mq32>
download a prebuilt tarbal, untar it and just rock everything ;)
<kenaryn>
There is none in the wiki for POSIX systems.
<kenaryn>
I tried zig/zig but it returns ^?ELF^B^A^A^C: Command not found.
<kenaryn>
Too many )'s.
<mq32>
huh
<mq32>
you're doing something weird
<kenaryn>
sorry I tried tcsh zig/zig
<kenaryn>
i just abandonned bash a week ago.
waleee-cl has joined #zig
<ceymard>
kenaryn: how about ./zig ?
<ceymard>
while being in the same directory
<kenaryn>
lol you were right, but now I have to export the new path variable but I do not know in which file, since tcsh do not call .bashrc to make the change permanent
<andrewrk>
I have a cup of tea and 6 hours of sleep. let's do this
<rifkik>
Andrew is on l33t Hacker Mode
kenaryn has left #zig ["(The show must go on.)"]
<LargeEpsilon_>
Hi, I have a small question regarding zig lang. Is it possible to use OpenMP with zig ? and if not for the moment is it planed to be supported one day ? Thanks in advance
halosghost has joined #zig
<Cadey>
LargeEpsilon_: what do you think that means?
<Cadey>
just so we're on the same page
porky11 has joined #zig
<LargeEpsilon_>
It would be the equivalent of #pragma omp X
<LargeEpsilon_>
for parallelization and SIMD
<LargeEpsilon_>
as supported by clang for C/C++/Fortran
dimenus has joined #zig
<fengb>
`try await try async fs.openReadWrite` that was so clunky :P
<andrewrk>
scientes, can you link me to your llvm talk?
<andrewrk>
fengb, yeah now it's try fs.openReadWrite
<andrewrk>
then I still need the hour it takes to pass CI to write up the Async Functions section. Haven't started that section yet :(
<scientes>
rather ./update_glibc ~/downloads/glibc ../lib
<scientes>
not sure where ~/downloads should be fixed to
<andrewrk>
I don't have the energy to do a really good async functions section in the release notes today. that's going to have to be a separate post or something
<scientes>
heh, the glibc build is like 15 hours
<andrewrk>
scientes, the first arg to ./update_glibc is the source tree of glibc
<scientes>
oh i got it
<andrewrk>
it's looking for those abi list files
<scientes>
~/multi/src/glibc
<ceymard>
is it possible to create new functions during compile time ?
return0e has quit []
<scientes>
ceymard, not yet
<scientes>
well, you are asking about a JIT, that is different from anonymous functions
<scientes>
is "32" in abi.txt glibc 2.22?
<ceymard>
scientes: so it is planned ?
<scientes>
ceymard, i'm not sure if you are talking about anonymous functions or a JIT
owl_000 has joined #zig
<ceymard>
neither
<ceymard>
I want to know if I can generate a function during comptime
<scientes>
I think anonymous functions would be able to do that
<ceymard>
just like inline for inlines a loop
<scientes>
like a template
<ceymard>
yup
<ceymard>
exactly like that
<owl_000>
is there function overloading or something like that
<owl_000>
in zig
<scientes>
owl_000, no, shadowing is explicitely disallowed
<scientes>
of course, if you use dynamic linking than that type of stuff still exists
<owl_000>
what is the procedure to pass float and int
<fengb>
If it’s template like behavior, you can do a lot of that with comptime args
<scientes>
owl_000, you can pass any type to "var", but you can't return arbitrary types yet, and that is controversial
<owl_000>
ok, i am actually trying out zig. but i like the idea of lean and clean c replacement.
<dimenus>
0.5 is almost here!
tencho has joined #zig
<owl_000>
`warn("{} {}",1,2);` #557 still exists
<owl_000>
why?
<fengb>
Because the workaround is probably easier than the fix
<euantor>
Guess I better prepare to update the chocolatey package - last time I was a day late and managed to get a comment asking where it was even with that short delay 😆
<andrewrk>
euantor, you still have ~40 minutes until the CI finishes :D
<andrewrk>
which is good, I'm still writing the release notes @_@
<euantor>
I'll get a PR open ready for it, then I just have to wait for the chocolatey reviewers
<konv>
andrewrk, is there any way I can help you with that?
<andrewrk>
konv, not anymore, it's almost done
<andrewrk>
you can help me in 6 months by reminding me to leave more than 1 week for writing release notes
<andrewrk>
ya'll were too damn productive this cycle
<owl_000>
351 issues were closed before this release. lot of work. great job
<ceymard>
why not having a changelog somewhere ?
<ceymard>
it would allow people to check on zig's development more often than every 6 months
<ceymard>
andrewrk: I meant something a little more curated :D
<ceymard>
but I get how it could be a hassle given the sheer amount of commits...
<andrewrk>
I'm happy with the division of time I've chosen on docs vs progress
doublex has joined #zig
owl_000 has quit [Ping timeout: 245 seconds]
earnestly has joined #zig
<andrewrk>
the fact that it's been 6 months since 0.4.0 will give us a nice media day today
<companion_cube>
is the release happening right now?
hasanyasin has joined #zig
<andrewrk>
CI is building the 0.5.0 tag. I'm wrapping up release notes, will have them uploaded soon
<hasanyasin>
Congratulations for 0.5!!!
<hasanyasin>
Newbie Question: Is there a native way to map strings to enum values directly? When I print an enum value, it prints the name instead of integer value, so I guess enum names are available as strings to the compiler already. If this could work vice versa as well, that would be awesome.
<fengb>
🎉
<scientes>
where does it strip -lc and -lm ?
<scientes>
when linking against the glibc stubs
<scientes>
anyways, that is kinda minor
<hasanyasin>
Typical use cases may be for example mapping headers/messages on text-based network protocols or command line arguments.
shritesh has joined #zig
<andrewrk>
hasanyasin, @enumToInt / @intToEnum
<hasanyasin>
I mean something like @labelToEnum? :D
doublex has quit [Ping timeout: 240 seconds]
<andrewrk>
oh, check std.meta
<hasanyasin>
Thank you!
doublex has joined #zig
LargeEpsilon_ has quit [Ping timeout: 276 seconds]
<hasanyasin>
This is so cool! With Go, to use enum labels like this (const names in Go), I would use code generation, so kinda two-phase compilation.
<hasanyasin>
andrewrk: Do you think it would fit the language style/design and your taste to have this function in std as a builtin such as @labelToEnum or maybe even T.fromLabel where T is any enum type?
fsateler has joined #zig
doublex_ has joined #zig
doublex has quit [Read error: Connection reset by peer]
<shritesh>
0.5.0 tests have passed!!!
<konv>
\o/
tencho has quit [Remote host closed the connection]
<andrewrk>
release notes done, uploading now
<halosghost>
:D
<tgschultz>
hasanyasin: std.meta was started with the opposite intention, to move builtins to userland code where possible. I'm not sure if that is still the direction we're headed or not though.
<hasanyasin>
I see!
<hasanyasin>
Maybe two separate directions make more sense based on the functionality. HashMap fits standard library perfectly when we have enums and enum labels can be used as strings with the mentioned function in std.meta.
<hasanyasin>
Of course, I am probably coming from a very different background than most Zig users so I may not be making any sense. Sorry if that is the case.
<Tetralux>
I'm not sure why you wouldn't just use a map with enum keys in that case
<Tetralux>
Or even just an array, depending.
LargeEpsilon has joined #zig
<hasanyasin>
All the keys are known at compile time so enum makes perfect sense. I am already very happy with what we have now. What I was trying to suggest is that if this is a very common case, maybe it would make sense to have this function as a builtin as well.
<hasanyasin>
Let's say you are writing an http server. In almost every modern HTTP server library that I used, method was defined as string which never made sense to me.
<hasanyasin>
In Go, you check request method as req.Method and it has type "string"
<hasanyasin>
There might be of course optimizations in compilation, but using integers for HTTP methods seems much more correct to me.
<fengb>
It's because the method can be arbitrary... eventually
<hasanyasin>
And with zig enums and std.meta.strToEnum, it is crazy easy and fun to do! :D
<fengb>
Spec is open to extending at any point
<hasanyasin>
fengb, do you mean HTTP spec?
<Tetralux>
You could have an enum with values .Get and .Post and then strToEnum and toUppercase (though, I don't think we have the second one in the stdlib.) :)
<Tetralux>
Or rather enumToString, or whatever it's called.
<Tetralux>
.. You know what I mean Xd
<fengb>
Yeah, IIRC PATCH was shoehorned in
<hasanyasin>
Yes, we already have this use case perfectly addressed in Zig. Compile time work is awesome.
<Tetralux>
+1
<Tetralux>
The more you can do at comptime, the better.
<tgschultz>
PseudoStructs can act as a sort of comptime-know-string 0-runtime-cost hashmap, but there's probably a simpler solution.
<hasanyasin>
fengb, I just tried to give an example with HTTP. When you are implementing a library for any protocol, it doesn't make sense to have your code cover future cases before those cases exist. :D If HTTP 3 brings in new protocols, your library will not know those protocols so it will be an error case for your version until you add the new methods to the enum type you designed.
<Tetralux>
tgschultz: I'm probably not gonna do it if it's not running the same code as at runtime.
<scientes>
just use HTTP/1.1 for now
<fengb>
I suppose that's true. I'm giving an excuse for existing implementations :P
<scientes>
that is WAY easier, and still works everywhere
<hasanyasin>
:D :D :D
<fengb>
Since technically the data is a string, keeping it as a string sorta makes sense
<scientes>
zig doesn't have strings
<hasanyasin>
scientes, that was just an example. What I was trying to say has nothing to do with HTTP actually.
plumm has joined #zig
<plumm>
just came to say congratulations :)
<rifkik>
Congrats!
<hasanyasin>
Yeah, very happy to see 0.5. I have already updated my local binary.
<scientes>
oh cool, it is here!
* halosghost
patiently awaits the release notes
<Tetralux>
It's kinda weird to do `zig version` and have it just say `0.5.0`
<Tetralux>
WHAT SORCERY IS THIS
<Tetralux>
:D
<tgschultz>
I'll have to schedule some time to update all my public code. Also to wrap my head around the new coroutines to see if replacing my state machine implementations with them would be cleaner.
<andrewrk>
TODO make code example of this -> NOPE! TODO: pull code example -> Nope!
<andrewrk>
Barabas, so you can see the fn signature
<andrewrk>
oh, I see
<andrewrk>
so many mistakes
<Tetralux>
I know the feeling
<FireFox317>
andrewrk, you're gonna put it on r/programming yourself?
<andrewrk>
no
<Tetralux>
Every time I write anything, I always check multiple times for errors, and then still have to spend 15 minutes fixing mistakes after I posted it xD
<andrewrk>
I'll upvote it really hard though
<andrewrk>
I usually do that but I ran out of time
shritesh has left #zig [#zig]
<Sahnvour>
congrats everyone on the release
<andrewrk>
you too Sahnvour
<FireFox317>
Posted!
<Sahnvour>
thanks ! now let's enjoy these release notes :)
* donpdonp
sees andrewrk's toot about 0.5.0 inside zootdeck that was built with 0.5.0. #winning
shritesh has joined #zig
<Barabas>
> Async functions are no longer generic, and do not require the async keyword. Zig infers that a function is async when it observes that the function contains a suspension point.
<Barabas>
Doesn't this make it hard to see whether a function is async or not?
<Barabas>
Especially when it's only async because calls another function which has a suspension point.
<andrewrk>
yes, similarly to how it's hard to see whether a function can execute at comptime or not
<Barabas>
Oh I see. Async functions can also be non-async, somehow. Kinda cool, also kinda confusing.
<andrewrk>
yeah that one. also this older one https://www.youtube.com/watch?v=YaROde0UESo (the bugs don't apply anymore) shows off resuming an async function in a different thread
<andrewrk>
I plan to make these demos in text form eventually
<andrewrk>
but right now I'm going to go have lunch
<Tetralux>
Barabas: `noasync async_function()` just asserts that the otherwise-async function does not actually suspend on that particular call.
<Cadey>
andrewrk: i really like that you managed to do async without hard depping an allocator
<plumm>
my main confusion is that global frame var, whats the point of that?
<Cadey>
that's just nuts to me at some level
<shritesh>
Cadey: Async functions also work across WASM boundary
<Tetralux>
plumn: The global frame is because when the function suspends, you have to "have a plan" for resuming it. In that example, you aren't using an event loop (which is normally how you'd do it), so instead, when it suspends it filled out the global with it's own frame, which is used to resume it later.
<shritesh>
You can suspend from zig and resume from wasm (vice versa too I guess).
<Cadey>
hahahahaha
<Cadey>
i love that
<Tetralux>
Normally, you wouldn't call resume or suspend manually; you'd use async/await instead.
<FireFox317>
That is so cool tho
<Tetralux>
> You can suspend [...]
<Tetralux>
Wait
<donpdonp>
andrewrk: unrequested advice incoming, I hope you take more than lunch off and rest up a bit. seems to be you're doing an incredible amount of work and management and burnout is real.
<Tetralux>
How
<Cadey>
i'm gonna compile that to webassembly and read the compiler output
<plumm>
Tetralux: is there not already an event loop?
<Tetralux>
plumn: Only if you make one and call .run on it, IIUC.
<Cadey>
plumm: the stdlib has one yeah
<shritesh>
If you're using WASM in a JS-host environment, it makes sense to use the JS event loop itself.
<Tetralux>
I'm not clear what std.event.Loop.instance [or whatever it's called] is about, though.
<Tetralux>
Does that get populated when you make an event loop? I'm guessing not.
LargeEpsilon has joined #zig
<Tetralux>
andrewrk: Also, the first example in 'Async Functions' -- does that not produce a compile error; the one about _start cannot be async?
<andrewrk>
thanks donpdonp
<andrewrk>
Tetralux, it's not doing `func()`, it's doing `async func()`. async fn call is not a suspend point; await is
<Tetralux>
Ah.
<Tetralux>
I guess I got a little confused because normally your examples have asyncMain() xD
<scientes>
daurnimator, does worksforarm have M-profile processors so i can test helium SIMD instructions?
<andrewrk>
I don't mind negative comments at all, but false claims with no evidence drive me insane
<plumm>
whos hurting you
<andrewrk>
it's just annoying to do the chore of responding so that drive by viewers don't get incorrect facts
<fengb>
Is this the guy who claims "Zig is too complicated"?
<andrewrk>
yeah haha
<FireFox317>
Jup those people will always be there
<Cadey>
haters gonna hate
<Cadey>
ponies gonna pwn
<Cadey>
etc
<tgschultz>
what happens if I `await` a function with `suspend` in it, having not called `resume` anywhere?
<Cadey>
shritesh: http://ix.io/1JT2 this is actually pretty interesting
<Cadey>
i like how simple it is
<Cadey>
you can see the suspend point getting inlined into the amain function
<Cadey>
er
<Cadey>
you can see it do the thing
<Cadey>
i words good not
<andrewrk>
tgschultz, then your `await` suspends indefinitely
<shritesh>
Yeah, `call_indirect` is where the magic happens.
<andrewrk>
tgschultz, it's a lot like not calling free(). it makes sense to not do sometimes, like with arena allocators
<tgschultz>
yeah, I'm just trying to figure out how I'd alter state machines that currently exist to use async instead, and if that would actually be less complicated or not. For my bmp lib, so far it seems like it wouldn't have any benefit in terms of cleaning things up. that isn't a criticism, it isn't really designed to replace arbitrary state machines.
<fengb>
tgschultz: I've cobbled together a paradigm for generators. That could possibly work for state machines
waleee-cl has quit [Quit: Connection closed for inactivity]
hasanyasin has joined #zig
LargeEpsilon has quit [Ping timeout: 245 seconds]
hasanyasin has quit [Ping timeout: 240 seconds]
shritesh has quit [Remote host closed the connection]
kristoff_it has quit [Remote host closed the connection]
kristoff_it has joined #zig
plumm has quit [Quit: Lost terminal]
mahmudov has joined #zig
kristoff_it has quit [Ping timeout: 268 seconds]
_Vi has joined #zig
konv has quit [Ping timeout: 268 seconds]
<Tetralux>
Wait - in the #2046, a backslash with a newline immediately after it isn't enough to disambiguate it?
<Cadey>
andrewrk: thank you for making async work without function colors
<fengb>
The most amazing thing is that blocking IO just works. I really didn’t expect that
<mikdusan>
Tetralux: .d escapes are shockingly bad; and also a prime example of technical debt
<Cadey>
oh damn
<Cadey>
this means i can make my templeos code ported to zig example about 500x more efficient
<Barabas>
Somehow while(pointer) and expecting it to stop when pointer becomes null doesn't work anymore?
<Barabas>
2/10 test "SingleLinkedList prepend"...cast causes pointer to be nullC:\Users\Bas\lib\zig\std\mem.zig:91:31: 0x7ff63edc39b6 in std.mem.Allocator::std.mem.Allocator.destroy (test.obj)C:\Projects\ZigZag\containers\single_linked_list.zig:41:39: 0x7ff63edc2bb8 in SingleLinkedList(u32)::SingleLinkedList(u32).deinit
<Barabas>
(test.obj)C:\Projects\ZigZag\containers\single_linked_list.zig:136:27: 0x7ff63edc1c54 in test "SingleLinkedList prepend" (test.obj)C:\Users\Bas\lib\zig\std\special\test_runner.zig:13:25: 0x7ff63ede360e in std.special.main (test.obj)C:\Users\Bas\lib\zig\std\special\start.zig:113:49: 0x7ff63ede33df in ??? (test.obj)
<Barabas>
oh, that's unreadable
<Barabas>
Tetralux interesting, looks similar to the error I get.
<Barabas>
Though that means I've run into two bugs =P
<Tetralux>
Consider yourself privileged :p
<fengb>
Hmm, logging gives me Node@1071d2038, Node@0
<Barabas>
The error points to the destroy function in the std lib
<Tetralux>
[[ I forget exactly where the ':' goes there. ]]
<fengb>
Oh yeah that should work too
<Barabas>
the const thing works
<Barabas>
And that other thing as well
<Barabas>
Thanks for looking into it :)
<fengb>
Use the other thing. it's more idiomatic
<Tetralux>
Basically - the error should be "cannot modify content of 'n' because it is unwrapped; you can copy it with an explicit assignment and use that instead or possibly use the after-loop statement."
<Barabas>
So that just calls destroy before re-assigning node, right?
<Tetralux>
Or rather - "because the unwrapped optional value is const" - sometihng like that.
<Tetralux>
Barabas: And yes.
<Tetralux>
Runs the loop block; runs the statement after ':'
<Barabas>
hmhm
<Tetralux>
Just like in:
kristoff_it has quit [Ping timeout: 240 seconds]
<Tetralux>
.. `while (i < n) : (i += 1) {}`
<Barabas>
There's some other test which fails now, so I'm betting that's due to a similar construct
<Barabas>
I don't know what the use case there is though. If you ever allocate different nodes with different allocators, you've to keep track of which node used which allocator somehow =/
<mikdusan>
Barabas: afaik all unwrapped optionals/unions/etc are aliases since result-location branch was merged. and this is how it's supposed to work
<Barabas>
hm... well it's confusing.
<mikdusan>
well it saves a forced copy
<Barabas>
sure...
<mikdusan>
i think if there was syntax like this it would help: `if (wrapped) |var unwrapped|` or something similar... that would handle your usecases and clarity, right?
<Barabas>
You can already do `if (wrapped) |*unwrapped|`
<Tetralux>
.. where 'var' generally means 'make storahe for this here'
<Barabas>
Which handles the 'I don't want a copy' usecase.
<mikdusan>
that's not the same thing; `*` means mutability
<Barabas>
hmm
<Tetralux>
well no
<Tetralux>
* means 'pointer to'
<Tetralux>
but yes
<fengb>
mikdusan: his case was that he mutated the original location, and it affected the unwrapped value
<fengb>
The code doesn't make it look obvious what's going on
<fengb>
It's sort of akin to how Go functions close around for loop variables. Sure we can learn it, but it still feels wrong
<Tetralux>
?
<mikdusan>
if the rule is "unwrapping makes alias" then it is obvious
<daurnimator>
scientes: on windows an access check is just an open+a close
<scientes>
yeah we already have os_file_exists
<daurnimator>
oh you mean from c++; not from zig itself
<scientes>
oh yeah, wasn't specific
<daurnimator>
andrewrk: in the Support Table I think we should colour things; freestanding maxes out at tier 2, so we should indicate that as a "good" state
<scientes>
so (void) doesn't silence the unused result....
<daurnimator>
wow. I got 19 mentions in the release notes
<scientes>
I got a bunch too
<daurnimator>
I think LemonBoy gets the high score of 61 though :P
<mikdusan>
62. "LemonMan" was used once :)
<nrdmn>
good evening!
<nrdmn>
I missed most of the party
kllr_sbstn has joined #zig
kllr_sbstn has left #zig ["Leaving"]
<Sahnvour>
nrdmn: the whole zig party is only beginning though :)
<nrdmn>
:D
kllr_sbstn has joined #zig
<kllr_sbstn>
Hey, is it possible to set a custom equals method for `std.testing.expectEqual`? I have structs containing floats, so the values don't need to be 100% exact.
Barabas has quit [Ping timeout: 260 seconds]
<daurnimator>
kllr_sbstn: you would write your own helper around std.testing.expect
<kllr_sbstn>
alright, i already do that. i thought there might be a a more 'clever' may. Thanks!
<kllr_sbstn>
*way
<daurnimator>
kllr_sbstn: expectEqual is simply a wrapper around expect itself
* scientes
always uses expect
<daurnimator>
scientes: expectEqual gives much nicer error messages. I use it when possible
<scientes>
ahh i see
<fengb>
I've noticed type inferrence to be much better when the literal is on the right :/