auto scope problem
Koroskin Denis
2korden+digitalmars at gmail.com
Tue Dec 4 06:48:24 PST 2007
Jarrett Billingsley Wrote:
> What compiler are you using, 0.173? The 'auto' keyword was replaced with
> the 'scope' keyword to perform RAII more than a year ago. I take it your
> full code looks like:
>
> void main()
> {
> auto x = new SomeClass();
> }
>
> In which case, yes, x will be deleted after main returns but only because
> the GC is run at program termination. The 'auto' here is just triggering
> variable type inference and nothing more. To get RAII, use 'scope':
>
> scope x = new SomeClass();
>
Of course no,
class Test
{
public:
this()
{
printf("constructed\n");
}
~this()
{
printf("deleted\n");
}
}
int main(char[][] args)
{
{
auto/scope Test t = new Test();
}
printf("exit main\n");
return 0;
}
Both auto and scope give just the same result:
"constructed, deleted, exit main"
About loop: it works now, however it didn't some time ago!
More information about the Digitalmars-d-bugs
mailing list