reference
reference copied to clipboard
Document `label_break_value` in the reference
r? @ehuss
Shouldn't this be called labelled block expression instead of labelled break expression?
Is this really a loop expression? It doesn't loop.
I take it that it is documented in loop expressions because it can only be used in loop expression context. Which I think is wrong. I don't see label-break-value as introducing a new kind of expression but rather modifies the semantics of just a block expression and break expressions. If I'm not too tired, I think I might create a competing pull request with how I think it should be documented; explaining it fully would be too much work.
Also, please oh please don't call this a labeled expression if we end up keeping this as its own expression kind. At least call it a labeled block expression or something.
I, uh, didn't write the PR today. I did think about perspectives some more, and now there's too many perspectives in my head. I wrote about them at https://rust-lang.zulipchat.com/#narrow/stream/237824-t-lang.2Fdoc/topic/Perspectives.20on.20Break.20Label.20Value
I'm nominating this issue as per the question raised on Zulip.
My two cents--
I think the approach in this PR seems fine, but I think we should have a link from wherever blocks are documented saying "labeled blocks are described under the loop section".
It's not clear that it's the best approach (if there is such a thing).
I tried to address @ehuss and @nikomatsakis's concerns. I renamed "label expression" to "label block expression".
@jyn514 It want to echo the comments of others that it feels really weird to document labelled blocks in a section named "Loop expressions"
Could we rename the "Loop expressions" chapter to something that doesn't indirectly imply that a labelled block somehow is a looping construct?
E.g. "Loop expressions and non-local jumps" or "Loop expressions and non-local control flow"? (Or even just "Non-local control flow" or "Complex control flow expressions"?)
Or "breakable expressions"?
I like "Loops and breakable expressions", that rolls off the tongue nicely.
("Loops and labelled block expressions" would also be fine, but I think "breakable expressions" jumps out with the purpose of the concept more immediately.)
I would also be happy with "Loops and other breakable expressions", to try to indicate why these things are in the same section.
I don't have objections to @pnkfelix's suggestion, but I don't know when I'll have time to apply them. Happy for someone else to push to my branch.
Happy for someone else to push to my branch.
Done!