www.digitalmars.com         C & C++   DMDScript  

digitalmars.dip.ideas - Regions: Scopes without scope

reply Quirin Schroll <qs.il.paperinik gmail.com> writes:
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
parent reply jmh530 <john.michael.hall gmail.com> writes:
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
parent Quirin Schroll <qs.il.paperinik gmail.com> writes:
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.
Sep 09