With statement become like C#'s using?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Aug 5 22:19:36 PDT 2013


On 2013-08-05 17:45:23 +0000, Bosak said:
> I think this dispose thing should be added to D, because it is a very 
> common practice in C#(and not only). In the book I used to learn C# 
> long ago I remember how they sayed like 100 of times: "If you use an 
> object that implements IDisposable ALLWAYS use it in an using 
> statement". It is not a strange or not-intuitive feature. In fact it 
> can make the "scoped" variables idea more popular. And instead of 
> explicitly adding an using statement you just declare your variable as 
> scoped and the compiler takes care of calling it's dispose 
> automatically when it gets out of scope.

In 
http://channel9.msdn.com/Events/Lang-NEXT/Lang-NEXT-2012/Three-Unlikely-Successful-Features-of-D 
I make the argument that C#'s "using" misses the point and D's "scope" 
statement is a better proposition.

Andrei



More information about the Digitalmars-d mailing list