With statement become like C#'s using?
Andre Artus
andre.artus at gmail.com
Mon Aug 5 11:14:10 PDT 2013
--snip--
> Bosak:
>
> class Resource { //can be any resource from files to streams to
> anything
> Resource[] used;
>
> void opDispose() {
> writeln("Resource disposed!");
You should avoid doing IO in a destructor/finaliser. Writing to
STDOUT can fail which may lead to resource leaks (if it throws).
> //in opDispose the resource should dispose all it's
> resources too
> foreach(res; used)
> res.opDispose();
> }
>
> static Resource open(string name){
> return new Resource;
> }
> }
--snip--
More information about the Digitalmars-d
mailing list