3 ms·
I feel like I'll have to read up some more to have the background to fully understand the article but one thing I wanted to point out is a difference between `f
by epage 3y ago
I feel like I'll have to read up some more to have the background to fully understand the article but one thing I wanted to point out is a difference between `fn rand_int(rand: &mut Random) -> i64` and `fn rand_int(ran: Random) -> (i64, Random)`, at least in Rust. With the version that moves `Random`, the return type is bigger and may spill over from registers to the stack which may cause a significant slow down, more than the code of Vale's generation check, I suspect.
I've run into this with my parser combinator library, winnow [0], and am considering switching from the nicer functional model of moving to the more imperative model of `&mut` [1].
[0]: https://docs.rs/winnow/latest/winnow/ https://docs.rs/winnow/latest/winnow/
[1]: https://github.com/winnow-rs/winnow/issues/72 https://github.com/winnow-rs/winnow/issues/72
- mike_hock 3y agoSpeaking more generally, to me this move-in-move-out interface design is a non-starter, so programming languages and compilers will have to come up with other solutions to avoid unnecessary checks. Which, AFAIK, Rust already has (there's runtime check on `&mut Random`), so TFA really is a Vale-specific micro-optimization.