What does scope do as storage class?

Nemanja Boric 4burgos at gmail.com
Sat Dec 23 21:38:36 UTC 2017


On Saturday, 23 December 2017 at 21:20:13 UTC, Jonathan M Davis 
wrote:
> On Saturday, December 23, 2017 21:05:25 Marc via 
> Digitalmars-d-learn wrote:
>> for example:
>>
>> scope struct S {
>>    int x;
>> }
>>
>> What does scope do here?
>
> Absolutely nothing.
>
> https://stackoverflow.com/questions/47240714/d-pure-classes-and-structs
>
> - Jonathan M Davis

There's one special case, though, with scope in classes - scope 
will force user to allocate class as a scope:

```
scope class X
{
	int x;	
}

void main()
{
	auto instance = new X;	// ERROR must be scope instance = new X;
}
```



More information about the Digitalmars-d-learn mailing list