On 12-02-29 04:41 PM, Niko Matsakis wrote:
This sounds fine. The only downside I can see to Marijn's technique is
that there is no way for an iteration function to distinguish "broke out
of the loop" from "returned out of the loop". This may or may not be
important? I could imagine that the iterator may want to perform actions
on a break which conceptually follow the loop but not perform those
actions on a return, but I can't actually come up with any convincing
examples.

Yeah, I can't either. And since we don't presently know, in other loops (while, vector-for), whether we exited them by loop-condition-completion or explicit-break, I can't see how this would deserve more-special consideration. If you have a Really Special Loop you can arrange a more subtle protocol between it and its iteratee.

Of course, here you end up with two temporaries where only one is needed
so it makes more sense to be smart about it. But it's good to know that
the translation does compose: I'd be worried otherwise.

Oh, weird! I had somehow convinced myself that it doesn't. Um .. well, if you can convince yourself it does, I don't mind the "slightly less efficient" version. Compositionality in the translation is probably more important than saving an extra copy.

So ... do we have a translation that actually gets us TCP-preservation on ret? If so that's _great_. We've been banging our heads against this and coming away disappointed since, er, possibly a year ago?

-Graydon
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to