--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--

Reply via email to