#[solved] Understanding undefined
1 messages · Page 1 of 1 (latest)
its the same as not giving a value to a variable in C
Also, is it the same as doing undefined for the default values of struct fields, or is that different?
var n: c_int = undefined; == int n;
so if I try to read it it would be garbage, and not zero-initialized?
yes
xy problem perhaps. what do you want to do?
You should try to not use undefined as the default value for a struct field, since that's an unsafe default
const Result = struct {
stdout :Data,
stderr :Data,
code :u8= undefined, // <------------
}
```This being the returning error of a shell command
but if Data, aka ArrayList is uninitialized, then it will just be empty. but u8 0 initialized could mean success
uninitalized does not mean "empty"
empty implies the array list is already initialized
Can you access an arraylist before its even ArrayList(T).init(allocator)?
if not, then its empty
not as far as i know
empty-uninitialized, empty-initialized its both empty
0 is not empty, its success
big difference
that's what I was trying to solve
i dont understand what you are trying to do
"u8 being initialized is success" does not sound like behavior you should rely on
empty has invariance though, its a state
an uninitalized array list is nothing, you cant get anything meaningful out of it
technically, maybe
in my brain, empty is just empty
"whatever version of empty this language technicalities implies as empty"
that's exactly the problem I'm trying to solve
0 should NOT be synonym with empty, when 0 means success
and uninitialized means garbage, so not reliable either
aka ?T= null is the only option
I don't write shell rules
isnt there a @boolFromInt?
thats called != 0
why would I want to return a bool from a shell command?
idk anything about shell commands, so idk
I want the exit code and a couple of strings
why do you not want to use optionals?