4 ms·
If you don't want to make it "opt-in" would it at least make sense to make it "opt-out"? Does Odin have a way for specific types to omit a zero value?
by Rusky 1y ago
If you don't want to make it "opt-in" would it at least make sense to make it "opt-out"? Does Odin have a way for specific types to omit a zero value?
- gingerBill 1y agoThat 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.
- Rusky 1y agoWhy would it require constructors? As opposed to simply enforcing that it always be initialized with a constant/variable/procedure/etc rather than zeroed.
- fc417fc802 1y ago> 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.
- O-stevns 1y agoYes, as mentioned here on the overview: https://odin-lang.org/docs/overview/#built-in-constants-values-and-procedures https://odin-lang.org/docs/overview/#built-in-constants-valu... x: int // initialized with its zero value y: int = --- // uses uninitialized memory