On Saturday, 23 April 2022 at 03:41:17 UTC, Alain De Vos wrote:
I wrote a simple test program:
```d
import std.stdio:writefln;

int [] GLV=[1,2];
int [2] GLF=[1,2];

// paste it ->>

static int [] GSLV=[1,2];
static int [2] GSLF=[1,2];

void main()
{

}
```

First of all, there is no such thing as a global region in D. Although the addresses are different, we have 2 regions:
* **AAA:** Stack
* **BBB:** Heap

Yes, there are a lot of expressions: ```static, const, immutable, shared etc.``` But the expressions matters to D compiler. Two concepts are important to us: the inter-module region and the ```main()``` function where the code starts to run.

Please paste the following into the inter-module region. Turn it on/off with the toggle (//) sign and see the difference.

```d
//auto data = iota(1024).array; /*

int[] data;
static this() {
  data = new int[1024];
} //*/

void main()
{
  writefln("%12x, %12x", &data[0], &data[$-1]);
}
```

SDB@79

Reply via email to