Can’t understand how comptime works in my code
I have a simple enum, that has a method to “convert” it to a colored string, but whenever I try to use it, I get an error “unable to resolve comptime value”, though this code is not intended to be ran on comptime, but even if zig is calculating all possible return values at comptime (since there is a very finite number of those) of this function:
How to organize large projects in Zig language
I used to break down my large c/c++ projects with CMake and then add each part to main project using add_submodule
command (the smaller parts were static or dynamic libraries). Also I used the same solution to use third-party libraries in my project.
Zig leaking memory from dynamically allocated ArrayList entries
I’m new to zig and learning it atm. So I tried to write my own unicode split function (because of reasons, please indulge me). Here it is:
How to split utf8 strings
I’m new to zig and learning it atm. When I use std.mem.splitAny
or splitSequence
or tokenize
to split a console input string with a space as delimiter, it returns garbage. So I tried to write my own unicode split function. Here it is:
What is the syntax for a for loop over an index with increment?
What is the syntax for having a for loop in zig with an increment?
In the code snippet below I wrote how it would look like in F#.
But how does it look like in zig?
Dynamic dispatch and vtables. Problem accessing types
I’ve been trying to create a system where i can store different types of data as “bundles”. The input order should not matter (i sort the input by their type), and i should be able to get only parts of the data.
Why is there very little use of pointers as parameters in the standard library of Zig?
While reading some of the standard library source code, I have encountered very little use of pointers for function parameters, even with const
, unless that specific parameter is edited by the function. From my perspective, it doesn’t seem very efficient as you are making a complete copy of the argument (obviously a shallow copy). So why is this? Is it better than passing something as a constant pointer, or is it just the “idiomatic Zig way”?
What is the “idiomatic Zig way” of doing these matrix operations as functions?
By idiomatic, I am referring to the way a Zig programmer would expect them to work. I have the following matrix structure:
What is the “idiomatix zig way” of doing these functions?
By idiomatic, I am referring to the way a zig programmer would expect them to work. I have the following matrix structure:
Does Zig reallocate at the same memory address when using the stack to manage allocations?
Please bear with this question as it might sound very dumb but this is my first experience with manual memory management.