<LewisGaul>
I can create an issue, just thought I'd get a second opinion, having been staring at this for so long haha
<g-w1>
create one, worst thing is it gets closed and you get an explination
<g-w1>
i would only include 1 & 2 though
<LewisGaul>
how come, don't they give distinct hints at what might be going on?
<g-w1>
3 includes more complexity, and it can be reduced with just 1 and 2
<g-w1>
you can include 3 if you want ig
<LewisGaul>
I'm confused, are we looking at the same thing? 3 is "no memory leak - direct arena deinit", which is the same as 1 "memory leak" but using `arena.deinit()` instead of `tree.arena.deinit()`
<g-w1>
we are
<g-w1>
my idea was that if it can be isolated with just 1 & 2, why include 3? but idc either way
<LewisGaul>
I think I'm just failing to understand the relation between 2 and 3, you may well be right :) I might as well include it all anyway
LewisGaul has quit [Quit: Connection closed]
<spacelove>
Is there an idiomatic way of getting the len of an ArrayList?
<spacelove>
To check if it's empty
<g-w1>
list.items.len :)
<spacelove>
How. HOW!
meinside has quit [Quit: Connection closed for inactivity]
<spacelove>
g-w1 so, I'm doing a breadth first search. Basically I'm wondering if I'm making a mistake by using arraylists instead of something more complex, like my own custom type. Basically I have an ArrayList of Nodes which makes a graph. Each Node has as a property a list of its neighbors. What I want to do is start with a node and find the shortest
<spacelove>
possible path to another one. So to do this I make a queue, which I will add arrays to (and pop off) as needed. To do all this popping and appending... maybe I'm wondering if ArrayList is the wrong thing, if maybe I have to implement my own datastructure. Thoughts?
<spacelove>
That probably made zero sense.
<g-w1>
a queue or a stack?
<g-w1>
stdlib also has a queue datastructure iirc
<spacelove>
queue... exists. wtf. amazing
<g-w1>
not like c lol
<spacelove>
I was so happy when I discovered string comparison
<g-w1>
spacelove: out of curiosity, how did you find out about zig?
<spacelove>
HackerNews, seemed hip
<g-w1>
nice :)
<spacelove>
Also, friends who do SWE
<g-w1>
SWE?
<spacelove>
Software Engineering
<g-w1>
ah
<spacelove>
in Sweden
<spacelove>
joking about that last part
<spacelove>
error: variable of type 'type' must be const or comptime
<spacelove>
var queue = std.TailQueue(StringArray); <-- there's no documentation on how to use this guy, have you seen him before?
<spacelove>
Please tell me when to stop btw, I will respect your autonomy or whatever.
<spacelove>
Please tell me when to stop btw, I will respect your autonomy or whatever.
<spacelove>
Oh shoot I did it again
linuxgemini has quit [Read error: Connection reset by peer]
lunamn has quit [Read error: Connection reset by peer]
ave_ has quit [Remote host closed the connection]
<spacelove>
Let me know if I can pm you, I will respect your time, but I feel like you have taken me under your wing and I don't want to necessarily spam the channel if my questions aren't super helpful for other people
<g-w1>
is this a question?
<spacelove>
Yea sorry.
<spacelove>
I am trying to understand why this doesn't compile. https://zigbin.io/c63dc9 Has the error message
<g-w1>
what is StringArray?
<spacelove>
I put it in the code. At the top
<spacelove>
I made it up because I needed arrays of strings a lot
<spacelove>
Maybe it's a doozy... idk.
<g-w1>
var array = StringArray.init(allocator); try array.append(start)
<g-w1>
(beware, dont know very much about algorithms)
<spacelove>
That's alright, I've got the algorithms under control
<g-w1>
nice
<spacelove>
I see what you did, so, the lesson is that you have to initialize arraylists before you can use them. Makes sense
<g-w1>
you probably also want to deinit them when you are done with them
<spacelove>
One step at a time baby
<spacelove>
I feel like Rocky at the end of every movie
selby has quit [Ping timeout: 256 seconds]
brzg has joined #zig
<spacelove>
g-w1 why did you learn Zig?
<g-w1>
I wanted to learn about compilers, and the compiler source code was soooooo good (much cleaner than any other compiler i saw) that I ended up writing a minimal standard library for my toy language in zig
<g-w1>
then i started working on the compiler lol
<spacelove>
I want to be like you
brzg has quit [Quit: leaving]
brzg has joined #zig
<g-w1>
spacelove: i only knew python and js a year ago. you can do it!
<spacelove>
That's me!
<spacelove>
Except minus the JS
<spacelove>
and minus the year
<spacelove>
And largely, minus the python
<g-w1>
oh, it must have been someone else who said they knew python :P
<spacelove>
My friend wants me to know if you use VSCode
<spacelove>
He's helping me over the phone right now
<g-w1>
i use emacs/neovim
<g-w1>
i used to use vscode ~1 yr ago tho :P
<spacelove>
Does your IDE tell you if your .zig will compile before you try to compile it
<spacelove>
(Sam is asking)
<g-w1>
no, zig language servers are not this advanced yet
<g-w1>
hopefully they will be soon
<g-w1>
for now, you have to compile it the old fashoned way
<spacelove>
Cool
<brzg>
nvim, on saving zig with zig.vim, will do a basic syntax check and run zig fmt
<sjd>
I know this is totally off topic for this channel, but would anyone be interested in a "usesthis" for developers? Seems like usesthis.com has lost its way in recent years, focusing 0 on devs and more on other random genres
<spacelove>
This seems like it should work.The data types match for .neighbors, initialize the array with init(allocator), but can't append the pointer to the other node. Getting this error:
<spacelove>
expected type '*std.array_list.ArrayListAligned(*const Node,null)', found '*const std.array_list.ArrayListAligned(*const Node,null)'
<spacelove>
on that last line.
<brzg>
i think you declared something as const instead of var
<brzg>
look at any relevant variable declarations, check if you made them immutable
<spacelove>
The struct has to be const. The node "node" is var
<spacelove>
Those are the only two relevant values afaict
<g-w1>
neighbord: *std.ArrayList(*const Node)
<brzg>
if the struct containing the ArrayList is const i don't think you can append
<g-w1>
if the struct is const, then it has to be a pointer
<brzg>
unless you use a pointer, as g-w1 is saying
<spacelove>
Says I'm trying to modify a constant value. But var Node is var...
<brzg>
this is a variable scope mistake
<brzg>
the node variable decalred in while (it.next()) is not the same as the node variable in for (grpah.items) |node|
jsb has quit [Quit: .]
<brzg>
try changing for (graph.items) |node| to end with |*node|
<g-w1>
yeah
<g-w1>
it needs a pointer anyways
<brzg>
the iteration sets node in a const way; changing to *node makes it a mutable pointer
<spacelove>
That makes each node into a type **const Node
<spacelove>
* is a pointer, what ** is I have never seen
<spacelove>
You can't access the attributes on a ** struct
<noam>
Stupid question: what's volatile do to asm?
<brzg>
** is a double pointer, don't know why that's showing up
<noam>
... I might break the asm syntax. This is ugly.
<noam>
(which makes sense, since it's descended from *GCC*'s asm(
<noam>
andrewrk: what's the identifier used for in the inline asm blocks? > [ret] "={rax}" (-> usize)
<noam>
the example in the docs references a nonexistent identifier.
<andrewrk>
noam, are you asking about the `usize` or the `ret`?
<noam>
The ret
<noam>
AFAICT it does literally nothing
<andrewrk>
in the assembly source, it can be used like this: `%[ret]`
<noam>
... huh. Neat.
<noam>
Why are they mandatory though?
<andrewrk>
it shouldn't be. if you use the `-> T` form there is no reason to use it
<noam>
Gotcha. Thanks for confirming :)
<noam>
One more tweak being made to the grammar here then :)
<andrewrk>
assembly syntax is one of the oldest parts of zig language, which has not yet received a design iteration
<noam>
Makes sense
<noam>
Ah yeah, didja see the progress in zyg? In the last day: test suite, scope rules, semantic analysis, arm64 and amd64 code generation, function calls, call and type graph generation, deferred execution, loops... :D
<noam>
Currently working on locals, slices / strings, and inline asm, should be done with those and more tonight :D
<spacelove>
pretty simple, not much pointer shit involved
<g-w1>
ah i see
<g-w1>
nice
<spacelove>
Ty
<andrewrk>
noam, can you link to some passing test cases?
<noam>
I don't have 'zyg test' written just yet, so my "test cases" consist of running an input through the pipeline and checking for errors, currently :P A few days should be enough to get actual execution and such, though that depends on how much effort I put into revamping the assembler
<g-w1>
spacelove: i have noted down some improvements to compile errors that would have helped you
<g-w1>
./zyg --target amd64 test/rk9/4.zig # then see the assembler output
<g-w1>
you must be on tmp branch though
<noam>
Yeah, because I need to do some squashing and cleanup before pushing to master :P
<noam>
but then i just kept doing more work!
<noam>
Might just move it for now and focus on better commit hygiene in the future instead
<noam>
... huh. I can't do the hacky asm injection I was going for ("msr " ++ reg ++ ", [out]") because it needs to be a string literal. Guess that means I'm working on enums / containerfields first
<noam>
Having an actual *goal* makes this all so much easier
<noam>
"I'm getting this done so I can use it to work on my bootloader" is a lot more motivating than "I'm getting this done because I enjoy it", weirdly, even though I *do* enjoy working on it
<noam>
Hmm, is there a good way to insert a comptime *string* into an inline asm bit? I want to read from special named registers, so in asm I'd write e.g. `msr CPUACTLR_EL1, <target_register>`. In Zig, CPUACTLR_EL1 does not bind to ANY zig variable (and can't! there's no direct access mechanism and the register allocator is obviously unaware of it), so it can't be fed in as an input.
<noam>
I *could* mod the assembler so I can feed in the bitstring that corresponds to CPUACTLR_EL1, but that just makes it harder to debug
<g-w1>
i suspect it will go down further with the tzir-memory-layout too!
yyp has joined #zig
meinside has joined #zig
ave_ has joined #zig
lunamn has joined #zig
linuxgemini has joined #zig
linuxgemini has quit [Read error: Connection reset by peer]
ave_ has quit [Remote host closed the connection]
lunamn has quit [Remote host closed the connection]
wootehfoot has joined #zig
lunamn has joined #zig
ave_ has joined #zig
linuxgemini has joined #zig
<v0idifyy>
hey, i can't call a function from itself if i `try` it, that's a bug right? cannot resolve inferred error set '@typeInfo(@typeInfo(@TypeOf(func)).Fn.return_type.?).ErrorUnion.error_set': function 'func' not fully analyzed yet
fireglow has quit [Quit: Gnothi seauton; Veritas vos liberabit]
LewisGaul has joined #zig
<ugla>
v0idifyy: Are you using inferred error sets? Seems to work for me if I do Error!void but not just !void: https://zig.godbolt.org/z/8roPrq
fireglow has joined #zig
zie has joined #zig
<v0idifyy>
ugla, yes, i'm using inferred
<v0idifyy>
but it should work right?
<ifreund>
v0idifyy: stage1 isn't smart enough to handle inferred error sets on recursive functions
<ifreund>
stage2 should be
<v0idifyy>
compiler bugs are fun
<v0idifyy>
because i get to be like "it's _actually_ not my fault!
<v0idifyy>
stack traces get confused on recursive functions, i guess that's normal
<v0idifyy>
openFile is failing on a relative path, is that normal?
<ifreund>
what error do you get?
<v0idifyy>
FileNotFound but i'm pretty sure it exists
<v0idifyy>
./dir/file is the path format
<ifreund>
if you're getting that error, then the operating system disagrees with you about whethere or not the file exists at that path relative to the directory you used
<ifreund>
you can use strace to see the exact syscall made if you want to double-check what the zig standard library is doing
<v0idifyy>
using absolute paths to /bin/sh works so it's weird, i
<v0idifyy>
i'll try that
<v0idifyy>
yeah it's my fault
<v0idifyy>
i called a openFile on a dir with a path from outside the dir
sord937 has joined #zig
LewisGaul has quit [Ping timeout: 240 seconds]
<v0idifyy>
is there a recursive makeDir?
<ifreund>
v0idifyy: makePath
<v0idifyy>
oh
wootehfoot has quit [Read error: Connection reset by peer]
remby has joined #zig
<v0idifyy>
i'm getting FileNotFound with createFile, what does it mean?
ave_ has quit [Read error: Connection reset by peer]
lunamn has quit [Remote host closed the connection]
linuxgemini has quit [Read error: Connection reset by peer]
<ifreund>
v0idifyy: probably you're trying to create a file in a dir that doesn't exist
<v0idifyy>
ifreund, totally didn't commit the exact same mistake
<v0idifyy>
is there other data formats apart from json in std?
<ifreund>
nope
bitmapper has joined #zig
<v0idifyy>
is there a thing that copies from reader to writer easily
<ifreund>
a fifo maybe?
<ifreund>
v0idifyy: yeah see LinearFifo.pump()
<v0idifyy>
ifreund, is there something that doesn't require an allocator? with a static buffer
<ifreund>
v0idifyy: a fifo can have a static buffer
<v0idifyy>
ugh i'll check the src. the docs are very useless :|
<ifreund>
yes, please ignore them and read the source :)
<v0idifyy>
how would it be possible to generate good docs of zig? or we will have to find a different approach to documentation(?)
<ifreund>
there's an open issue about it, it's definitely a solveable probalem, just not something that makes sense to solve in stage1
sord937 has quit [Ping timeout: 268 seconds]
<v0idifyy>
`anytype` generates different assembly for each version of the function right?
sord937 has joined #zig
CommunistWolf has quit [Ping timeout: 244 seconds]
<ifreund>
afaik yes
CommunistWolf has joined #zig
lunamn has joined #zig
ave_ has joined #zig
linuxgemini has joined #zig
<v0idifyy>
would it be a good idea to have typed anytypes (interfaces)? i'm sure you already thought about it
<ifreund>
if you want runtime interfaces on the other hand, there are plenty of patterns for that
remby has quit [Quit: remby]
m4r35n357 has quit [Quit: Ex-Chat]
cole-h has joined #zig
remby has joined #zig
mikdusan has quit [Quit: WeeChat 3.0.1]
<ifreund>
andrewrk: opened a PR for my first zir-memory-layout patch, if you think what I've done there makes sense I'll start pushing to the branch directly
dreda_ is now known as dreda
<v0idifyy>
hmm, am i supposed to be able to have a function pointer with a first parameter as a self?
<v0idifyy>
like: const A = struct { thing: fn (self: A) void }; fn func (self: A) { }; var a = A{.thing=func}; a.thing(); // (instead of a.thing(a);)
<v0idifyy>
i'm pretty sure this is a compiler bug (it errors to compile something like this) because allocator.<func>(unrelated params) always works fine