forked from dlang/dmd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdep_scope_type.dd
28 lines (22 loc) · 884 Bytes
/
dep_scope_type.dd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
`scope` as a type constraint on class, struct, and enum declarations is deprecated.
`scope` as a type constraint on class declarations was meant to force users
of a class to `scope` allocate it, which resulted in the class being placed
on the stack rather than GC-allocated. While it has been scheduled for
deprecation for quite some time, the compiler will emit a deprecation warning
on usage starting from this release.
`scope` as a type constraint on struct or enum declarations has never had any
effect, and has been deprecated as well.
---
scope class C { } // Deprecation: `scope` as a type constraint is deprecated. Use `scope` at the usage site.
scope struct S { } // Ditto
scope enum E { } // Ditto
---
Using `scope` to stack-allocate `class` is still suported,
only the type constraint is deprecated.
---
class C { }
void main () @nogc
{
scope c = new C;
}
---