On 9/29/11 5:25 AM, Marijn Haverbeke wrote:
I guess we could use return-by-alias here, yes. I was kind of assuming everybody hated that and wanted it to go away. But if we use that we can no longer return a tag to indicate end of sequence (you can't currently wrap a reference in a data structure -- supporting that would get way too hairy).
True, it's a bummer. At some point you just need to start using swap if you want to avoid copies. Or you iterate by index only (probably the least painful solution).
This sort of thing is why I think @ is going to end up being pretty common in real-world code. Not too bad IMHO; optimizing heap allocation is well-studied, after all. We're still leagues better than Java on the memory management front because we support stack allocation.
A bigger issue is when you want to iterate over stuff on the exchange heap, of course. For that we'll just have to see how swap turns out. I foresee having a borrowable pointer type (basically just a sugary mutable option::t) in the standard library.
Patrick _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
