ok, here is the first thing that I noticed, reading your blog post/review.
> No undefined values ... > C allows you to use an uninitialized variable which can result in Undefined Behavior. I’ll assume that’s what this means. ... > Typically, uninitialized values come from a memory allocation that hasn’t been written to. ... > Let’s see if we can get the V compiler to allocate memory for us without writing to it:
fn main() {
a := []&int { len: 1 }
println(a)
}
That program segfaulted in the automatically generated string conversion method for the println() call (you created a 1 element array of pointers, and since each of the elements is initialized to 0, you got a 0 pointer, then println tried to show that, but the automatically generated string conversion method did not check for 0 pointers -> the segfault).TLDR: the autogenerated string conversion method has a bug, that will be fixed soon.
Ironically, the cause is the opposite of what you intended to show - the memory for the new array was initialized to 0.
I would have appreciated a bug report in https://github.com/vlang/v/issues , that could be properly tracked till resolution, but apparently people these days have an entire month to dedicate on writing a "review" with a "Rules of engagement" section, but do not have 5 minutes to submit a github issue ¯\_(ツ)_/¯ ...
btw, if you instead of the above did:
fn main() {
a := []int { len: 1 }
println(a)
}
the program (printing `[0]`) will have worked correctly.Edit: I've filed this in https://github.com/vlang/v/issues/14786