Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Zig is also a systems language, yet it doesn't have this problem because every local variable must have an explicit initializer. So this simply won't compile:

  pub fn main() void {
     var x: i32;
     ...
  }
If you do actually want an uninitialized variable, you say so:

  var x: i32 = undefined;
This rule also takes care of structs by applying recursively.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: