reference icon indicating copy to clipboard operation
reference copied to clipboard

Document `label_break_value` in the reference

Open jyn514 opened this issue 3 years ago • 10 comments

r? @ehuss

jyn514 avatar Sep 06 '22 13:09 jyn514

Shouldn't this be called labelled block expression instead of labelled break expression?

nbdd0121 avatar Sep 06 '22 13:09 nbdd0121

Is this really a loop expression? It doesn't loop.

ciphergoth avatar Sep 07 '22 02:09 ciphergoth

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.

Havvy avatar Sep 07 '22 05:09 Havvy

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

Havvy avatar Sep 08 '22 08:09 Havvy

I'm nominating this issue as per the question raised on Zulip.

Havvy avatar Sep 08 '22 21:09 Havvy

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).

nikomatsakis avatar Sep 13 '22 18:09 nikomatsakis

I tried to address @ehuss and @nikomatsakis's concerns. I renamed "label expression" to "label block expression".

jyn514 avatar Sep 14 '22 02:09 jyn514

@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"?)

pnkfelix avatar Sep 20 '22 19:09 pnkfelix

Or "breakable expressions"?

nbdd0121 avatar Sep 20 '22 19:09 nbdd0121

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.

pnkfelix avatar Sep 20 '22 21:09 pnkfelix

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.

jyn514 avatar Sep 23 '22 02:09 jyn514

Happy for someone else to push to my branch.

Done!

pnkfelix avatar Sep 27 '22 19:09 pnkfelix