www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - What does scope do as storage class?

reply Marc <jckj33 gmail.com> writes:
for example:

scope struct S {
   int x;
}

What does scope do here?
Dec 23 2017
parent reply Jonathan M Davis <newsgroup.d jmdavisprog.com> writes:
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
Dec 23 2017
parent Nemanja Boric <4burgos gmail.com> writes:
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; } ```
Dec 23 2017