[rust-dev] Fall-through in alt, break&continue by label

Sebastian Sylvan sebastian.sylvan at gmail.com
Sun Apr 15 18:17:34 PDT 2012


On Tue, Apr 10, 2012 at 5:53 AM, Henri Sivonen <hsivonen at iki.fi> wrote:
> It appears that Rust does not to have labeled loops with break and
> continue by label the way Java has.  Also, it appears that alt does
> not have fall-through the way switch in C has.
>
> Are break and continue by label and/or fall-through in alt supported
> in some non-obvious and unadvertised way?  If not, are there plans to
> add to these features?  (While I understand that fall-through in
> switch is largely considered a misfeature, break and continue by label
> seem less controversial.)
>
> If there are no plans to add these features, what are the recommended
> ways to emulate these features in a way that compiles to efficient
> machine code?

Could tail calls work? I.e. each "label" would equal a separate
function (any state would have to be passed through), and then you'd
just keep tail-calling from state to state. Without really knowing
exactly what kind of code you're trying to generate, this seems like
it might be workable.

Seb


-- 
Sebastian Sylvan


More information about the Rust-dev mailing list