With statement become like C#'s using?

Adam D. Ruppe destructionator at gmail.com
Mon Aug 5 06:54:37 PDT 2013


On Monday, 5 August 2013 at 13:42:01 UTC, Michal Minich wrote:
> But what Bosak proposes is that when "with" statements ends, 
> the object should be destructed

That would happen if the object is a struct, or wrapped in a 
struct, since it would go out of scope at the end of the with and 
call its destructor then.

So then you could just go

import std.typecons;
with(auto a = Scoped!T()) { ... }

and the Scoped destructor does the deleting.


More information about the Digitalmars-d mailing list