return0e has quit [Read error: Connection reset by peer]
return0e has joined #zig
zfoo_ has joined #zig
_Vi has joined #zig
shakesoda has joined #zig
decentpenguin has joined #zig
<fengb>
Um... I translated most of the op codes and that’s about it :P
zfoo_ has quit [Ping timeout: 260 seconds]
LER0ever has quit [Remote host closed the connection]
slowtyper has quit [Quit: WeeChat 2.7]
slowtyper has joined #zig
frmdstryr has joined #zig
utzig has joined #zig
dddddd has joined #zig
marmotini_ has joined #zig
zfoo_ has joined #zig
ScottJMaddox has joined #zig
ScottJMaddox has quit [Remote host closed the connection]
metaleap has joined #zig
TheLemonMan has joined #zig
<TheLemonMan>
yo, is any windows user able to reproduce the test failure in #4497 ?
<TheLemonMan>
my windows VM is extremely slow and getting Zig to compile is gonna take too much time
<shakesoda>
can i use comptime stuff to generate symbols to export
<shakesoda>
i'm trying to figure out what i can do to approach exporting stuff with this crazy macro-powered name mangling that haxe's hashlink libraries need
<TheLemonMan>
sure thing, @export allows you to set the external name for every symbol
<shakesoda>
wonderful, looks like exactly the tool for the job, i will see where this path leads
<shakesoda>
thanks
<andrewrk>
I think @bytesToSlice and @sliceToBytes can be removed from the language in favor of functions written in zig
<TheLemonMan>
outstanding idea, that saves me the need to find out why the PR is erroring out heh
<fengb>
That'd make sense, especially since `asBytes` and `bytesAsValue` are already there
<fengb>
`testing.expect(codeface.* == 0xC0DEFACE);` I think someone was having fun
marmotini_ has quit [Remote host closed the connection]
marmotini_ has joined #zig
daurnimator has quit [Ping timeout: 272 seconds]
marmotini_ has quit [Ping timeout: 260 seconds]
<shakesoda>
does zig have a good way to alias types such that the two types won't be compatible without at least an @as, or should i do something like have a struct/union with a single field
<metaleap>
oh neat, somehow i only had fmt.printAlloc in mind but with bufs itd work
<fengb>
Note: bufPrint only uses a slice... I'm starting to wonder if we should rename std.Buffer
<betawaffle>
also speaking of error sets... i think i may have found a bug recently
<metaleap>
fengb: so much of this (incl my above usecase) can be userland-rolled that i suppose more commonly needed things will keep arriving into std.meta
<betawaffle>
i think the compiler might have trouble with inference when peer-type resolution is involved?
<ForLoveOfCats>
Potentially dumb question: Is it possible to build a struct at comptime with some sort of loop? I am trying to take a `[]FnArg` and package it up as a type which can be passed to `@call` (I'm wrapping std.Thread.spawn to allow me to pass more than one arguments as an anonymous struct)
<betawaffle>
in that, foo would be inferred to have an empty error set (it seems), and bar would not
<betawaffle>
am i missing something?
<betawaffle>
or is that a bug?
<andrewrk>
ForLoveOfCats, your issue is #383
<betawaffle>
ForLoveOfCats: not currently possible to build a new struct at comptime
<ForLoveOfCats>
So there is a compiler limitation on this and it is different from what ArrayList(T) does by returning a struct at comptime?
<betawaffle>
you can make structs at comptime, just not with comptime-dynamic fields/decls
<ForLoveOfCats>
That's what I thought you meant, thanks for clearing that up
<metaleap>
well for decls there was some abusingnamespace hackery floating around but .. yeah =)
<betawaffle>
metaleap: i'm still not sure i'd consider that comptime-dynamic
<metaleap>
yeah couldnt do it in a loop or such i guess
<metaleap>
still, conditional decls. it's something. if one is into that sorta thing
<betawaffle>
oh?
<metaleap>
dont remember how that worked but usingnamespace was involved and its operand was comptime-decided to be empty struct or struct-with-stuff. might have been outdated too
<betawaffle>
i really wish zig had a "flags" type that could be used in the way enums are often abused in C
<fengb>
Oh is this guy `pron` on HN?
<fengb>
betawaffle: packed structs
<andrewrk>
oh wow nice connection fengb
Akuli has joined #zig
<betawaffle>
that's not very fluent, and it's difficult or impossible to convert to that from a C enum
<ForLoveOfCats>
Is there any hack that will allow generating the name of a struct field's name? (I'm headed down a rabit whole with the `pub usingnamespace` hack)
<companion_cube>
fengb: yes
<ForLoveOfCats>
*hole
<fengb>
*rabbit
<fengb>
I need a troll emoji
<mikdusan>
fengb: we already have a troll emoji. it's `fengb` :P
<fengb>
Fine, I need a serious emoji
<andrewrk>
betawaffle, in my experience regular ints with constants work pretty fine for flags, same as C
<companion_cube>
🤔 does the job fengb
<betawaffle>
yeah, they work "fine" but you don't get any type safety
<andrewrk>
but yeah align(0) fields (#3802) would be the ziggy type safe way to do it
<andrewrk>
fengb, this guy looks exactly like me
<companion_cube>
andrewrk == pron??
<fengb>
Well that explains all the Zig propaganda from his HN account /fengb
<companion_cube>
nice use of /fengb /s
<andrewrk>
maybe the discord channel will add a custom fengb emoji
<andrewrk>
on IRC you would have to get it into the unicode standard
<companion_cube>
or make your IRC client rewrite ":fengb:" into some picture
<fengb>
💩
<andrewrk>
me: monads are too hard to understand
<andrewrk>
also me: skipping the part of the video where he explains how monads work
<fengb>
Since I’m basically shitposting anyway
<fengb>
Hmm I think I’ve seen this. Is this where he proposes CPS as a solution?
<companion_cube>
wait until he reaches callback hell
<companion_cube>
tbh it's a good presentation of monads from a concrete point of view
<companion_cube>
it's all about the executor
<andrewrk>
ok I sat through monad explanation. still do not understand
<fengb>
Which is funny... because a stackless async is kind of a style of CPS
<betawaffle>
andrewrk: monads are for *mumble mumble mumble*
<andrewrk>
wait, an error union is a monad?
<companion_cube>
`Result<T,E>` is a monad for a fixed E, yes
<fengb>
Anything is a monad if you squint hard enough
<companion_cube>
lol, no
<companion_cube>
but clearly, Option/Result/List/Future are good examples
<fengb>
Optionals, promises, Linq
<companion_cube>
… yes? :D
FireFox317 has quit [Remote host closed the connection]
<companion_cube>
it'd be funny if the things he presents about scoped continuations were equivalent to zig's async
<andrewrk>
I hate that "then" pattern that js has
<andrewrk>
18:20
<andrewrk>
IMO callbacks are better than that
<fengb>
Disagree. Callbacks can't capture state and compose correctly
<companion_cube>
andrewrk: don't worry, he gets on with better solutions
<fengb>
So you end up having some weird hack to prevent multi-firing
<companion_cube>
let imperative langs be imperative!
<andrewrk>
this is the other way around: you would "inject" more C code before importing, to perhaps expose macros or do other type annotations
ur5us has joined #zig
<betawaffle>
the things i want to do are: rename things, exclude thing from being exported, and either replace some function argument types, or provide hints to avoid cases of [*c] types
FireFox317 has quit [Quit: Leaving]
<betawaffle>
oh also... i want to be able to define methods and such on some of the generated structs/enums/etc
<andrewrk>
this use case adds a lot of complexity that isn't strictly necessary
FireFox317 has joined #zig
<betawaffle>
the latter thing would be completely unnecessary if we have newtype
<betawaffle>
ok... what about this... what if @cImport was gotten rid of completely, and instead made available as part of the build system?
<betawaffle>
in a way that we could write whatever we wanted to post-process the result before it gets turned into a zig file
<mikdusan>
well the build system won't stop you from doing that right now
<andrewrk>
it's already available as part of the build system
<andrewrk>
b.addTranslateC
<betawaffle>
hmm
waleee-cl has joined #zig
slowtyper has quit [Read error: Connection reset by peer]
<andrewrk>
this proposal is to annotate the C source code
<andrewrk>
e.g. if you have access to modify the upstream .h files
<betawaffle>
well, it discusses some other things
<betawaffle>
tbh, if @refiy was a thing, i wouldn't have a problem
<betawaffle>
i also really want @result()
<betawaffle>
(pointer to result location)
<andrewrk>
the latter is #2765
jjido has joined #zig
<betawaffle>
andrewrk: would it need to be a pointer, or does zig have the concept of it being a value in a particular location? ie. could you do @result() = foo, or would you need to do @result().* = foo?
<andrewrk>
the latest proposal is that it would be a normal variable declaration and zig would infer that a certain variable is always returned at every exit point. if you relied semantically on this working, then you would get a compile error if it didn't happen with #3803 or #3804
<andrewrk>
consider #2761 for why @result() is problematic
<Sahnvour>
mikdusan: I am indeed building llvm myself, but I wouldnt understand how it affects compiling a stage1 .o file
dingenskirchen1 has joined #zig
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen1 has quit [Client Quit]
dingenskirchen has joined #zig
<FireFox317>
ah andrewrk, i see you already merged #4435, nice!
<FireFox317>
However, i think the test that you added currently won't pass, because how the code is currently structured it has to resolve all the decls before it knows the length.
<FireFox317>
I'm currently working on trying to make each decl entry lazy, instead of the whole slice
<andrewrk>
FireFox317, well it does pass
<andrewrk>
:)
<FireFox317>
hmm
<andrewrk>
TheLemonMan, can we reach some kind of agreement on #3971?
<FireFox317>
ah i see, in the test case you are looking at the fields of the struct, not the decls
<TheLemonMan>
sure thing, I have no better idea tho
<andrewrk>
FireFox317, yes and that test did not pass previously
<andrewrk>
araspik, note this will affect some language features such as threadlocal variables and ensuring the stack size is large enough, and some std lib features such as accessing environment variables and process parameters
frmdstryr has quit [Ping timeout: 272 seconds]
mahmudov has quit [Remote host closed the connection]
meraymond2 has quit [Remote host closed the connection]
kristoff_it has joined #zig
wilsonk has quit [Ping timeout: 268 seconds]
wilsonk has joined #zig
<araspik>
andrewrk: that's all fine, I just wanted to see how small a program I could make. Thanks!
<andrewrk>
araspik, here are some relevant flags: --release-small --strip --single-threaded
<araspik>
andrewrk: It's not working, seems to expect a semicolon in place of `callconv(.C)`
<araspik>
wait, it compiled with `pub fn _start() callconv(.C)` and no return type?!
FireFox317 has quit [Ping timeout: 260 seconds]
<araspik>
... never mind, `objdump` shows no assembly was left within, I used flags `--release-fast --single-threaded -ffunction-sections -fno-PIC -fno-stack-check --strip`
<andrewrk>
all of these are redundant for your case: -ffunction-sections -fno-PIC -fno-stack-check
<andrewrk>
you need to export _start
<andrewrk>
pub export fn _start
<araspik>
it's still giving me weird parsing errors
<TheLemonMan>
...are you using the 0.5 compiler?
<araspik>
without `callconv(.C)`, it says that it expects `noreturn` on a line which already has `noreturn`
<araspik>
with `callconv(.C) noreturn`, it expects a semicolon after `callconv(.C)`
<pixelherodev>
That automatically adds it to package.use and emerges it
<TheLemonMan>
the command gets longer and longer heh
<araspik>
TheLemonMan: Not if you use `EMERGE_DEFAULT_OPTS`
<araspik>
But that shlt grows
<pixelherodev>
That's not that bad
<pixelherodev>
Keeping in mind that the equivalent on e.g. Debian would involve adding an unstable repository
<araspik>
try writing out some highly specific update/resume command and you'll see what long looks like
<pixelherodev>
Yeah, I had one that was ~10 lines recently
<pixelherodev>
Because my package.mask was wrong :(
<araspik>
I hate it when `emerge` sets up bad stuff automagically
<araspik>
Once I had weird stuff going on in `package.use` that was forcing the introduction of a few use flags and stuff all because of this one package I'd installed (and then uninstalled) a while back
<pixelherodev>
To be fair, it only happened because I was using LibreSSL
<araspik>
the more exotic the setup, the longer the command
<pixelherodev>
And not all ebuilds properly support it
<pixelherodev>
Yeah
<araspik>
the worst I've been in is trying to synchronize Ruby or Python versions across all packages
<pixelherodev>
Heh, Python2's final EOL in Gentoo is going to be *fun*
<pixelherodev>
Though to be fair, anyone using Gentoo will probably know how to do that :P
<araspik>
very true
<araspik>
if you can keep a Gentoo system up-to-date for over a month then you have learnt almost everything you will ever need to know
<pixelherodev>
Here's a fun idea: Suicide Linux + Gentoo :P
<araspik>
`words[0].execute`
<araspik>
or `words[4]`, depending on how you look at it
<pixelherodev>
?
<araspik>
suicide, dude
<araspik>
suicide
<araspik>
also btw `emerge '=dev-lang/zig-9999'` is easier than optionally escaping based on shell
<araspik>
I've updated the wiki accordingly
<pixelherodev>
Right, thanks
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
araspik has quit [Remote host closed the connection]
slowtyper has quit [Ping timeout: 260 seconds]
slowtyper has joined #zig
<jaredmm>
With a return type of *const [somefunc(input) :0] u16, is there a way to capture the function result in the body or do you have to run it twice?
frmdstryr has joined #zig
<andrewrk>
jaredmm, you have to run it twice
<andrewrk>
it's cached the second time
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
utzig has quit [Quit: leaving]
<ForLoveOfCats>
Just to make sure my understanding is correct, async/await is completely seperate from threading yes? The whole concurrency vs parallelism jam
<jaredmm>
Hm. That means this is three loops for W literals with a mostly duplicated function to calculate the codepoint length.
<andrewrk>
ForLoveOfCats, the short answer is "yes". what OS are you currently on?
<ForLoveOfCats>
Linux 4.19 x64
<ForLoveOfCats>
How does async/await differ between supported platforms?
<ForLoveOfCats>
I'm reading through https://github.com/andrewrk/zig-async-demo/tree/master/factorial and it makes the claim that async/await allows parallelism but my understanding of them is that they allow concurency via a coroutine-like (I know you don't like that word as it has different meanings to different people) style but without parallelism, what am I missing?
<andrewrk>
ForLoveOfCats, it doesn't differ between platforms. here's a "hello world" async/await program: https://clbin.com/LRUS6 try running that with strace and see that it's not interacting with the OS at all
<andrewrk>
I asked only before suggesting to use "strace" :)
<ForLoveOfCats>
Ah, makes sense
<ForLoveOfCats>
So what am I missing?
<ForLoveOfCats>
I was under the impression that async/await allowd for concurency but not parallelism, but the above demo claims to demonstrate parallelism
<ForLoveOfCats>
and by you're own statement here of it not interacting with the OS at all further implies that it is indeed not throwing up new threads to run in parallel
<ForLoveOfCats>
*your
<andrewrk>
this is the code that runs before main(). if you opt in to evented I/O mode then zig initializes a global std.Event.loop
<andrewrk>
...which spawns a thread pool
<ForLoveOfCats>
Wait, so evented IO changes more than how IO is handled by the std internally?
<andrewrk>
no, that's all it changes
kristoff_it has quit [Ping timeout: 272 seconds]
<ForLoveOfCats>
But that's still not parallelism for the developer's written code
<andrewrk>
basically, if you add `pub const io_mode = .evented;` next to your `pub fn main` then your zig application will have concurrency semantics very similar to Go
<andrewrk>
I'm not following
<ForLoveOfCats>
If that changes only how actual IO is handled, how does that allow general non-IO application logic to be written for parallelism?
<andrewrk>
the default mode of the std lib event loop is a thread pool, with 1 worker thread per cpu core. so if you were to, for example, var f = async foo(); var b = async bar(); and then foo() and bar() do I/O, that will end up with threads executing in parallel
<andrewrk>
you can also force it with std.Event.loop.startCpuBoundOperation()
<andrewrk>
the beautiful thing about startCpuBoundOperation() is that it is a no-op in single threaded applications and blocking I/O applications
<ForLoveOfCats>
So there *is* an toggleable global thread pool for non-IO application async/await?
FireFox317 has quit [Ping timeout: 260 seconds]
<andrewrk>
I don't understand the question
FireFox317 has joined #zig
<andrewrk>
the only global thread pool is in lib/std/event/loop.zig. you can grep the codebase to see what calls it. it's really not very complicated
<andrewrk>
I'm sorry I'm not trying to be obtuse. I know the documentation for this is very poor
<ForLoveOfCats>
I'm currently re-reading the documentation for this to better express my confusion (maybe even pick something out which fits together with something you've said here)
FireFox317 has quit [Client Quit]
<jaredmm>
What would a Zig representation of a definition like `typedef struct tagMOUSEHOOKSTRUCTEX : tagMOUSEHOOKSTRUCT { DWORD mouseData; } MOUSEHOOKSTRUCTEX, *LPMOUSEHOOKSTRUCTEX, *PMOUSEHOOKSTRUCTEX;` be?
<andrewrk>
jaredmm, you can find out by putting that in foo.c and then running: zig translate-c foo.c