From 28d15a6e783a334166271e24471fb6bba64886a8 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 5 Nov 2026 00:25:53 +0000 Subject: [PATCH] Disable autoformatting in examples of weird formatting. (#8090) Rumdl has grown the ability to format python snippets. That's not what we want in an example whose purpose is to show off some weirdly-formatted python code! So turn it off. Also turn it off for the weirdly formatted Swift and Kotlin code here which rumdl doesn't reformat today, but might reformat tomorrow. --- proposals/p002665-semicolons-terminate-statements.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/proposals/p002665-semicolons-terminate-statements.md b/proposals/p002665-semicolons-terminate-statements.md index 5d7999ca2b91..5a228ed5ec37 100644 --- a/proposals/p002665-semicolons-terminate-statements.md +++ b/proposals/p002665-semicolons-terminate-statements.md @@ -83,12 +83,14 @@ In Python, a line is a parentheses are an idiomatic way to create multi-line statements. Semicolons may be used to explicitly separate statements. For example: + ```python value = ( "text" ) a = 1; b = 2; c = 3 ``` + Swift allows some statements to wrap lines, although multiple statements on the same line (`x = 1 x = 1`) require a semicolon. The detailed rules aren't @@ -101,6 +103,7 @@ documents that line-breaks are treated as whitespace. However, there are observable ways the behavior can lead to small mistakes; these may may often be caught by the compiler, but will sometimes be missed. For example: + ```swift // One statement in Swift, but two in Python and Kotlin. var x = 1 @@ -115,6 +118,7 @@ Make() () Make() () ``` + Kotlin permits a newline to be used to terminate statements instead of a semicolon. Kotlin's grammar @@ -122,12 +126,14 @@ semicolon. Kotlin's grammar the places where newlines can appear (see mentions of `NL` in the grammar), and doesn't allow newlines in places where they would introduce ambiguity. + ```kotlin // This is unambiguously parsed as two statements, because // a newline is not permitted before a `+` operator. var x = 1 + 1 ``` + In JavaScript and TypeScript, semicolons are part of the formal syntax, and ECMAScript provides