digitalmars.dip.ideas - Regions: Scopes without scope
- Quirin Schroll (25/25) Sep 05 The unofficial purpose is to introduce the term “region” for a
- jmh530 (2/9) Sep 05 What would be the benefit of this?
- Quirin Schroll (2/13) Sep 09 Teachability.
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:
```d
pragma(region) // operators
{
}
```
or
```d
pragma(region) /+ operators +/ {
}
```
The biggest difference to `#pragma
those are ended with `#pragma endregion` and that allows them to
be non-nesting.
Sep 05
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?
Sep 05
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:Teachability.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?
Sep 09








Quirin Schroll <qs.il.paperinik gmail.com>