Re:Zig: programming language designed for robustness optimal...
by Yoric on Wednesday May 30, 2018 @08:14AM
(#17187037)
> Sure. I think that's more an effect of the choice of keyword defaults here. A straight union is very uncommon and is typically solely for C interoperability.
Fair enough. That's why Rust also has a `union` keyword, which is always `unsafe`.
> A tagged union can store data as in Rust. See the examples in the documentation [1]. Admittedly Rust's pattern matching is nicer to work with here.
Ah, right, it could be any struct instead of being a bool or integer. I missed that.
> If referring to if objects are guaranteed to be deallocated when out of scope then no, this isn't checked.
I was wondering about that and double-deallocations.
> There are a few active issues regarding some improvements to resource management but it probably won't result in any automatic RAII-like functionality.
Fair enough. That's why Rust also has a `union` keyword, which is always `unsafe`.
> A tagged union can store data as in Rust. See the examples in the documentation [1]. Admittedly Rust's pattern matching is nicer to work with here.
Ah, right, it could be any struct instead of being a bool or integer. I missed that.
> If referring to if objects are guaranteed to be deallocated when out of scope then no, this isn't checked.
I was wondering about that and double-deallocations.
> There are a few active issues regarding some improvements to resource management but it probably won't result in any automatic RAII-like functionality.
Out of curiosity, what kind of improvements?