4 ms·
Nitpick: Rust includes a GC. Box<T> is reference counted, although the reference count is always 1 until it is released by the owner, then it reaches 0. The ref
by kzrdude 11y ago
Nitpick: Rust includes a GC. Box<T> is reference counted, although the reference count is always 1 until it is released by the owner, then it reaches 0. The reference counts are inferred statically for the most part.
:-P
- Ericson2314 11y agoAlways inferred statically for box.
- Gankro 11y agoNo, if you conditionally move a box, there needs to be runtime checks for whether that condition occured when in it goes out of scope. (note that reassignment of a variable effectively causes the old value to go out of scope -- this may have Implications for your loops, though I sure hope you aren't making and destroying boxes in a loop!) In my experience, this is not however a significant concern.
- Ericson2314 11y agoOoops yeah forgot about https://github.com/rust-lang/rfcs/blob/master/text/0320-nonzeroing-dynamic-drop.md https://github.com/rust-lang/rfcs/blob/master/text/0320-nonz.... [To be perfectly pendantic, one could trade the drop flags for code bloat and have only a finite blow up and statically known everywhere, so its a "weak" form of dynamism.]
- Gankro 11y agoYeah I guess you could have exponentially many statically compiled paths for each combination of drop flags... but then you're just encoding your drop flags in the instruction pointer :) edit: this of course implies an easy program with 65 conditionally moved boxes that can't be encoded under your system.
- Ericson2314 11y agoIt's all true. Someday, long from now, I'd like to do a crater run with eager drop and see if anything actually breaks.
- kzrdude 11y agoCStrings and drop guards everywhere break