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

That would require having constructors, which is not something Odin will ever have nor should it. However you can just initialize with a constant or variable or just use a procedure to initialize with. Odin is a C alternative after all, so it's a fully imperative procedural language.


Why would it require constructors? As opposed to simply enforcing that it always be initialized with a constant/variable/procedure/etc rather than zeroed.


> you can just initialize with a constant or variable or just use a procedure to initialize with.

Is there an option to leave something uninitialized? I often find the allocation of explicitly uninitialized objects to be a performance necessity in tight loops when I'm working with numpy.


Yes, as mentioned here on the overview: https://odin-lang.org/docs/overview/#built-in-constants-valu...

x: int // initialized with its zero value

y: int = --- // uses uninitialized memory




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

Search: