| 1 |
// (non-control structure) local scope Object cleanup |
| 2 |
// 1.5.2.5 (ge) added |
| 3 |
|
| 4 |
// a class |
| 5 |
class Foo |
| 6 |
{ |
| 7 |
int val; |
| 8 |
|
| 9 |
fun @construct( int x ) |
| 10 |
{ x => val; } |
| 11 |
|
| 12 |
fun @destruct() |
| 13 |
{ <<< "destructor:", val >>>; } |
| 14 |
} |
| 15 |
|
| 16 |
// control structure scope |
| 17 |
if( true ) |
| 18 |
{ |
| 19 |
// nested scope |
| 20 |
{ |
| 21 |
Foo foo(-1); |
| 22 |
<<< 1, "" >>>; |
| 23 |
|
| 24 |
// nested nested scope |
| 25 |
{ |
| 26 |
Foo bar(-2); |
| 27 |
<<< 2, "" >>>; |
| 28 |
} |
| 29 |
<<< 3, "" >>>; |
| 30 |
|
| 31 |
} |
| 32 |
<<< 4, "" >>>; |
| 33 |
|
| 34 |
} |
| 35 |
<<< 5, "" >>>; |
| 36 |
|
| 37 |
// top-level scope |
| 38 |
{ |
| 39 |
Foo foo(0); |
| 40 |
} |
| 41 |
<<< 6, "" >>>; |