Thread overview | |||||
---|---|---|---|---|---|
|
December 23, 2017 What does scope do as storage class? | ||||
---|---|---|---|---|
| ||||
for example: scope struct S { int x; } What does scope do here? |
December 23, 2017 Re: What does scope do as storage class? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Marc | 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 |
December 23, 2017 Re: What does scope do as storage class? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | 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;
}
```
|
Copyright © 1999-2021 by the D Language Foundation