Thread overview
Regions: Scopes without scope
4 days ago
Quirin Schroll
4 days ago
jmh530
11 hours ago
Quirin Schroll
4 days ago

The unofficial purpose is to introduce the term “region” for a brace-delimited section of code that does not introduce scope. For example, static foreach and static if don’t govern a block, they govern a region. The actual DIP idea is to introduce a construct to make a pair of braces to denote a region anywhere the programmer sees fit.

The idea is simple: pragma(region) { … } is a region, which means the braces don’t introduce a block with scope. In any reasonable editor, it can be collapsed.

Parsing a region is fairly simple: Pretend it’s not really there, akin to a comment. Speaking of comments, you can use a comment to name a region:

pragma(region) // operators
{
}

or

pragma(region) /+ operators +/ {
}

The biggest difference to #pragma region of MSVC or C# is that those are ended with #pragma endregion and that allows them to be non-nesting.

4 days ago

On Friday, 5 September 2025 at 10:24:03 UTC, Quirin Schroll wrote:

>

The unofficial purpose is to introduce the term “region” for a brace-delimited section of code that does not introduce scope. For example, static foreach and static if don’t govern a block, they govern a region. The actual DIP idea is to introduce a construct to make a pair of braces to denote a region anywhere the programmer sees fit.

[snip]

What would be the benefit of this?

11 hours ago

On Friday, 5 September 2025 at 12:26:11 UTC, jmh530 wrote:

>

On Friday, 5 September 2025 at 10:24:03 UTC, Quirin Schroll wrote:

>

The unofficial purpose is to introduce the term “region” for a brace-delimited section of code that does not introduce scope. For example, static foreach and static if don’t govern a block, they govern a region. The actual DIP idea is to introduce a construct to make a pair of braces to denote a region anywhere the programmer sees fit.

[snip]

What would be the benefit of this?

Teachability.