<pixelherodev>
Maybe you could translate-c the generated .h lol
<THFKA4>
right..hah
<THFKA4>
extern seems like it would work, but that means specifying the signature for every method by hand
nephele_ has joined #zig
mq32 has joined #zig
<THFKA4>
anyway..the current workaround seems to be to use the generated .h. thanks everyone
nephele has quit [Ping timeout: 256 seconds]
nephele_ is now known as nephele
dddddd has quit [Ping timeout: 246 seconds]
doublex has quit [Ping timeout: 260 seconds]
doublex has joined #zig
aerona has joined #zig
xackus_ has joined #zig
xackus has quit [Ping timeout: 256 seconds]
xackus has joined #zig
xackus_ has quit [Ping timeout: 260 seconds]
kaun_ has joined #zig
rappet_ has joined #zig
rappet has quit [Ping timeout: 246 seconds]
skrzyp has quit [Ping timeout: 260 seconds]
Techcable has joined #zig
aerona has quit [Quit: Leaving]
slowtyper has quit [Quit: WeeChat 2.8]
slowtyper has joined #zig
ur5us has quit [Ping timeout: 256 seconds]
fraktor has joined #zig
tdc has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
ur5us has joined #zig
mokafolio has quit [Remote host closed the connection]
mokafolio has joined #zig
cole-h has quit [Quit: Goodbye]
st4ll1 has quit [Quit: WeeChat 2.8]
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
ur5us has quit [Ping timeout: 256 seconds]
kaun_ has quit [Ping timeout: 256 seconds]
dermetfan has joined #zig
dermetfan has quit [Ping timeout: 260 seconds]
greenfork has joined #zig
kaun_ has joined #zig
dermetfan has joined #zig
drp has quit [Remote host closed the connection]
drp has joined #zig
ifreund has joined #zig
ur5us has joined #zig
alexnask has joined #zig
marijnfs has joined #zig
skrzyp has joined #zig
Chris660 has joined #zig
doublex has quit [Remote host closed the connection]
doublex has joined #zig
skrzyp has quit [Remote host closed the connection]
daex has quit [Ping timeout: 256 seconds]
daex has joined #zig
ur5us has quit [Ping timeout: 256 seconds]
dermetfan has quit [Ping timeout: 260 seconds]
skrzyp has joined #zig
kaun_ has quit [Ping timeout: 246 seconds]
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen1 has joined #zig
dingenskirchen1 is now known as dingenskirchen
craigo has joined #zig
skrzyp has quit [Quit: WeeChat 2.7.1]
daex_ has joined #zig
daex has quit [Ping timeout: 246 seconds]
dddddd has joined #zig
ask6155 has joined #zig
<ask6155>
Hello!
<ifreund>
hi
<alexnask>
o/
<ask6155>
Someone said to me to have a growable array I need to use ArrayList, but I'm confused what an array list is. the documentation says its a function and it also has fields(??) and also an init and deinit function. How do I use it?
<ifreund>
ask6155: It's a comptime function that returns a type, this is how generics are implemented in zig
<ifreund>
var mylist = ArrayList(u32).init(allocator);
<ifreund>
mylist.append(42);
<ask6155>
huh, thanks!
<ask6155>
and... what allocator to use?
st4ll1 has joined #zig
<ask6155>
std.heap.heapallocator?
<alexnask>
Depends on what you are doing. For a general purpose allocator there is not a really good option except for std.heap.c_allocator rn but std.heap.page_allocator is good enough for testing
ifreund has quit [Quit: WeeChat 2.8]
daex has joined #zig
daex_ has quit [Ping timeout: 246 seconds]
<ask6155>
Hey what does expression value ignored mean?
<ask6155>
./fac.zig:19:25: error: expression value is ignored array.append(i);
<bgiannan>
append returns the added element
<bgiannan>
you can't ignore the returned value
<bgiannan>
or you have to write _ = array.append(i)
<bgiannan>
well you can ignore it you just have to do it explicitely
<ask6155>
but the declaratio says return !void
<ask6155>
oh wait !void means it may return an error.
<alexnask>
Yes append doesnt return the element, you are ignoring the error
<alexnask>
You have to `try arr.append(...);` or `arr.append(...) catch |err| // Do stuff with the err`
<ask6155>
ok
marijnfs_ has joined #zig
marijnfs has quit [Ping timeout: 240 seconds]
jmiven has quit [Quit: reboot]
Chris660 has quit [Remote host closed the connection]
jmiven has joined #zig
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
marijnfs has joined #zig
<ask6155>
ok I've been trying to work with ArrayList but I guess I'm dumb and I am only getting errors. I have a const with points to std.heap.page_allocator and I pass that to ArrayList(i32).init(alloc) but I cannot append.
marijnfs_ has quit [Ping timeout: 246 seconds]
mokafolio has quit [Read error: Connection reset by peer]
mokafoli- has joined #zig
mokafoli- is now known as mokafolio
<ask6155>
append says value is ignored and when I discard it, it says error is discarded.
nmeum has quit [Read error: Connection reset by peer]
nephele_ is now known as nephele
SyrupThi- is now known as SyrupThinker
dingenskirchen has quit [*.net *.split]
Biolunar has quit [*.net *.split]
drewr has quit [*.net *.split]
Dominic[m] has quit [*.net *.split]
<alexnask>
ask6155, YOu have to handle the errors, either using try or catch. (`try expr;` is equivalent to `expr catch |err| return err;`)
dermetfan has joined #zig
<alexnask>
You can't discard errors
Biolunar has joined #zig
dingenskirchen has joined #zig
dingenskirchen is now known as 874AAIOJ9
drewr has joined #zig
dingenskirchen has joined #zig
dingenskirchen has quit [Ping timeout: 256 seconds]
874AAIOJ9 is now known as dingenskirchen
dermetfan has quit [Ping timeout: 244 seconds]
drewr has quit [Ping timeout: 256 seconds]
drewr has joined #zig
<ask6155>
what does span do?
<alexnask>
It returns the items slice, its deprecated you should use .items directly instead
<alexnask>
Not sure why it wasnt turned into a compile error, the other deprecated stuff is
<ifreund>
i think that deprecated stuff sticks around for one release cycle before becoming a comipile error or something
<scientes>
where is zig fmt's canonicalization?
<ask6155>
well I want to convert my ArrayList to a list literal (because easier to pass?) which function would do that?
<scientes>
oh nvm
<scientes>
i was confusing format.zig and fmt.zig
<ifreund>
mylist.items
<ifreund>
which is a slice and what I assume you mean by "list literal"
<ask6155>
After my work with a growable array I wanted to make it fixed size so I can pass to another function which would read it. (If there's a better way please suggest I'm from C land)
<alexnask>
As ifreund said items is the slice (aka pointer + length), if you also want to transfer ownership you can call toOwnedSlice which will shrink the memory to exactly what is needed and return the slice (obviously then you have to manually free the slice)
<bgiannan>
how do i append a string literal to a ArrayListSentineled(u8, 0) ?
<alexnask>
.appendSlice
<bgiannan>
ah thx i see it now
skrzyp has joined #zig
<ask6155>
how do I take Cli input?
<ask6155>
std.os.read?
<ask6155>
is stdout defined?
<alexnask>
std.io.getStdIn() will return stdin as a File
<alexnask>
Same with stdout and stderr
<alexnask>
(a std.fs.File, that is)
greenfork has quit [Quit: WeeChat 2.8]
<ask6155>
thanks I guess my first program is finally finished. It doesn't do much, just pukes out all the factors.
<ask6155>
of a number
ask6155 has left #zig ["bye!"]
drewr has quit [Quit: brb]
drewr has joined #zig
<bgiannan>
How do i bufPrint into a ArrayList buffer? Before i was doing a std.fmt.format with a callback that counted how much bytes i needed so i could resize my Buffer and bufPrint into it
<bgiannan>
but std.fmt.format has completely changed
<leeward>
I think you can make a stream out of an ArrayList and .print to it.
<bgiannan>
right, just saw ArrayList.outStream
greenfork has joined #zig
shakesoda has joined #zig
<shakesoda>
zls has substantially improved my zig experience
<bgiannan>
so Buffer is gone and along with it toSliceConst. How do i make slice const now?
<alexnask>
usingnamespace coming soon to a zls near you
<leeward>
I'm not certain what you mean, but maybe mem.spanZ?
<leeward>
Ah, yes. `pub const toSliceConst = @compileError("deprecated; use std.mem.spanZ");`
<bgiannan>
seems to work thanks!
<leeward>
\o/
marijnfs_ has joined #zig
marijnfs has quit [Ping timeout: 240 seconds]
waleee-cl has joined #zig
craigo has quit [Quit: Leaving]
frett27_ has quit [Ping timeout: 272 seconds]
marijnfs has joined #zig
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
marijnfs_ has quit [Ping timeout: 246 seconds]
marler8997_ has joined #zig
<marler8997_>
I'm having an issue with package-path, not sure if it is a bug or not
<marler8997_>
In my http client project, I use package path to set the "ssl" package to either an openssl or nossl variation
<marler8997_>
but now when I'm using that library in another project, even though I'm setting the "ssl" package, the modules in my http client project cannot find the "ssl" package
<marler8997_>
is that as-designed?
stripedpajamas has joined #zig
r4pr0n has joined #zig
<r4pr0n>
is it planned to have an iterator interface in the stdlib with some abstract functions like there are in rust?
<fengb>
So far, the pattern seems to be `var iter = create(); while(iter.next()) |val|`
<fengb>
Since we don't have traits (yet), I'm not sure making anything more concrete is on the plate
<karchnu>
fengb: traits?
<r4pr0n>
yes, but if there is some kind of interface, you can get a lot of higher level functions just by implementing .next() and maybe .len()
<r4pr0n>
it's not about the iterating over it
<fengb>
Rust traits are concretely defined
<fengb>
You can do that already with Zig and duck type generics
<r4pr0n>
well there's a interface for allocators
<fengb>
That's runtime based
<r4pr0n>
hm yeah
<fengb>
I suppose it's possible... but I wouldn't expect Zig to go that direction
<fengb>
Our functional patterns are pretty limited
<ifreund>
ew, did anyone else get opted back in to the new reddit automatically?
<companion_cube>
so, same concept, ok
<marler8997_>
yeah pretty much
<fengb>
I opted back to old reddit and it's sticking for me
doublex has quit [Ping timeout: 260 seconds]
doublex has joined #zig
SimonNa has quit [Remote host closed the connection]
cole-h has joined #zig
stripedpajamas has quit [Quit: sleeping...]
FireFox317 has quit [Quit: Leaving]
ur5us has joined #zig
r4pr0n has quit [Remote host closed the connection]
metaleap has joined #zig
r4pr0n has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
stripedpajamas has joined #zig
ur5us has quit [Ping timeout: 256 seconds]
ur5us has joined #zig
daex has quit [Ping timeout: 264 seconds]
daex has joined #zig
stripedpajamas has quit [Quit: sleeping...]
stripedpajamas has joined #zig
r4pr0n has quit [Quit: r4pr0n]
<gonz_>
I have a browser extension that forces old reddit
<alexnask>
Is this necessary? You can just opt out of new reddit in your acc settings
<gonz_>
I don't know, apparently it didn't take for ifreund. I don't remember when I added it, to be honest, or whether or not there was an option to opt out then either.
dermetfan has joined #zig
JimRM has joined #zig
<JimRM>
Hi all! I've got a question for you
<JimRM>
I am playing with some code I found on GH, which hasn't been updated in a while. So I am guessing a lot of stuff has changed with zig. The part I am struggling with is this:
<JimRM>
pub var mbox: [36]u32 align(16) = []u32{0}**36;
<JimRM>
Any code which looks like:
<JimRM>
mbox.mbox[7] = 0;
<JimRM>
Fails to compile with:
<JimRM>
error: array literal requires address-of operator to coerce to slice type '[]u32'
<JimRM>
Can someone explain how the code should look now?
Akuli has joined #zig
<fengb>
`[]u32{0}**36` needs to be `[_]u32{0}**36`
stripedpajamas has quit [Quit: sleeping...]
<JimRM>
Thanks! What does that do? Is it explained in the docs?
<JimRM>
Does he `[_]` make it a slice?
<fengb>
Nope, it was previously ambiguous parsing
<alexnask>
No, this is array literal syntax `[N]T { init list }`, `_` just infers the number of elements
<fengb>
`[_]u32{0}` creates an array of an implied size (equal to 1 here)
<JimRM>
Ahhh!
<fengb>
Previously we used `[]u32{0}` for the same construct, but it was confusing to both new users and the parser
<fengb>
So the underscore was added `[_]`
<JimRM>
So what was the compiler generating when it was `pub var mbox: [36]u32 align(16) = []u32{0}**36;`
<JimRM>
I mean I could get it to compile if I commented out any array accesses.
<fengb>
It should generate a syntax error since `[]u32{` is no longer correct
<fengb>
Oh that's probably because Zig is lazy
<JimRM>
Hm, yeah I was just about to say
<fengb>
If a variable isn't referenced, it won't get compiled in. So only basic parsing runs without semantic analysis
<JimRM>
It looks like commenting out that code was commenting out all uses of it
stripedpajamas has joined #zig
<fengb>
Yeah, Zig is allowed to erase `const` references
<JimRM>
Is there a way to enable "eager" compilation?
<JimRM>
for example I may define a bunch of code that isn't used immeadiately, (say a bunch of consts from a hardware manual) I'd rather know I've messed something up now than in 6 months time when I come to use one for the first time
ur5us has quit [Ping timeout: 260 seconds]
<leeward>
JimRM: That's a common issue, and the best solution that you can use now is to refer to things in tests.
<JimRM>
So I have spent about 4 hours so far looking at Zig and I really like it so far. Reading the objdump output for AARCH64 is super nice too. It's pretty close to reading dumped C code (ie easy ;) )
<JimRM>
I am trying Zig after spending quite some time writing Bare metal with Rust.. but decided I really wanted a nicer C
<gonz_>
Zig certainly fits that description a lot more than many alternatives. Welcome. :)
<JimRM>
Thanks :) - I was curious what the development process was like for the zig toolchain. Is it community driven/multiple contributors?
<fengb>
So the basic rule of thumb is... anything that's power-of-2 is safe. Anything under 1 byte is safe. Everything else... needs testing
ifreund has quit [Ping timeout: 256 seconds]
ifreund has joined #zig
stripedpajamas has quit [Quit: sleeping...]
greenfork has quit [Ping timeout: 256 seconds]
<andrewrk>
sorry folks. the dilemma here is opportunity cost. if we can ship stage2 with working packed structs then we can actually just delete packed structs from stage1
<mq32>
andrewrk: sounds like a perfect plan to me
<mq32>
don't waste time on stage1 packed structs, it's not worth it
<mq32>
it's not necessary for writing a compiler
<ifreund>
andrewrk: yeah I think that makes a lot of sense
<ifreund>
I don't need them at all personally of course :)
<BaroqueLarouche>
I used packed struct in my PE code
ur5us has joined #zig
<andrewrk>
I'm working on wiring up Zig AST to ZIR right now, so once that's in place, it will start to feel like progress is accelerating because there will be more and more behavior tests passing in self-hosted
<leeward>
They're useful for anything that has to talk to networks too, but it's not like we can use Zig in production yet, and getting packed structs working in stage1 will actually delay that.
<mq32>
leeward: exactly
metaleap has quit [Quit: Leaving]
stripedpajamas has joined #zig
tdc has quit [Ping timeout: 264 seconds]
marijnfs_ has joined #zig
marijnfs has quit [Ping timeout: 258 seconds]
Akuli has quit [Quit: Leaving]
<tdeo>
hmm, can we have non-exhaustive unions to match with non-exhaustive enums?
tencho has quit [Ping timeout: 264 seconds]
<ifreund>
hmm, does tagging a union with non-exhaustive enum do that already?
<andrewrk>
tdeo, there is an open pull request for that
<andrewrk>
by xackus
<andrewrk>
I took a quick peek at it and I just want to make sure I understand all the ramifications before merging
<tdeo>
ooh, didn't know
FireFox317 has joined #zig
<tdeo>
> I think they are useful, however they should not need a _ => branch in switches, since they cannot be initiated with unnamed values.
<xackus>
nah, my pr is just a bugfix
<tdeo>
hmm, i actually want that behaviour for future api compatibility
<tdeo>
since wayland can add messages in api-compatible protocol versions
<andrewrk>
it would basically mean all the unnamed values get the `void` type, as I understand it
<tdeo>
but it's not a big deal if the zig type system can't enforce that
<FireFox317>
nice andrewrk! I'm looking forward to seeing the first Zig code be compiled with the self-hosted compiler (this time using our own codegen :D) Is it coming along nicely?
<andrewrk>
yes; I'm hoping to have a very primitive hello world in master today
<BaroqueLarouche>
neat!
<tdeo>
wow!
<FireFox317>
wow did not expect that :P
<xackus>
i was fixing non-exhaustive enums and encountered the same bug in union code
<tgschultz>
despite merging upstream/master with my own master, and rebasing my branch on that, there are files missing.
<tgschultz>
I only changed one file, so all I want to do is blow away everything, rebase on current master, and plop my file back down.
<tgschultz>
I'm sure there's some branch of mathematics where this behavior makes sense
stripedpajamas has joined #zig
<tgschultz>
I sorta got it, but there still a file I didn't change in my pull request somehow
<tgschultz>
screw it. change isn't worth the effort.
<ifreund>
tgschultz: for future reference the most foolproof way to do this is `git fetch upstream; git rebase upstream/master` from the branch you want to get up to date
<ifreund>
no need to mess around with keeping a local master up to date or anything
<tgschultz>
I did that
<ifreund>
if you do a `git rebase -i upstream/master` are there changes listed that you don't expect?
<ifreund>
if so you can drop those commits in the interactive rebase
<tgschultz>
I'll make a not for the future but I've already deleted that branch
<tgschultz>
thank you for the help, regardless
<ifreund>
no problem, git is a stupidly complex beast :D
<ifreund>
it is quite useful and has become indispensible to me though
<pmwhite>
Is anybody here active on mastodon/fediverse? I would enjoy hearing people's progress on Zig projects and having Zig related discussion. It might help attract new users from there as well.
<ifreund>
nah, github is my only social media these days if you don't count various chat service
<ifreund>
i guess I can give progress updates here though, my compositor is coming along nicely and I've started to get a few contributors!
<rooke>
ooh I really enjoyed your talk on that ifreund got me thinking about writing one now :x
<ifreund>
rooke: go for it! wayland is a lot of fun
<pixelherodev>
ifreund: if you had to sell me on your compositor over e.g. Sway, what would you say?
<ifreund>
pixelherodev: dynamic window manament makes manual tiling feel slow and clunky after you get used to it
<pixelherodev>
... dynamic tilign?
<pixelherodev>
tiling*
<ifreund>
also its simpler cause I'm not supporting all the features of i3
<ifreund>
dynamic tiling means that the windows arrange themselves based on a predefined layout
<rooke>
haha I'd be basically porting hlwm to sway, too used to manual tiling
xackus has quit [Quit: Leaving]
<ifreund>
you generally have one "master" window that is larger and several smaller windows which you can travese through and promote to the master slot
<ifreund>
I didn't come up with this idea of course, it's what dwm, xmonad, awesomewm, etc. do but nobody made one for wayland yet