|
Archives
D Programming
digitalmars.Ddigitalmars.D.bugs digitalmars.D.dtl digitalmars.D.ide digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger D.gnu D C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript electronics |
digitalmars.D.learn - Are scope class useful ?
When I started D, it was possible to define a scope class like this.
scope class Something
{
// blah
}
An instance declaration would then _require_ the scope storage class.
{
scope Something myVar;
// do something with Something
}
Is there a use case for such a feature.?
Jan 05 2010
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 #ponce wrote: Jan 05 2010
Yes. One of the uses is when you are wrapping some sort of OS resource. I've got a scope class which I use for file access; stops you accidentally leaving the file open & locked. I also use scope classes for storing intermediate results in complex algorithms when I want deterministic collection. Use scope classes and it all gets cleaned up when the algorithm finishes. Jan 06 2010
div0:I also use scope classes for storing intermediate results in complex algorithms when I want deterministic collection. Use scope classes and it all gets cleaned up when the algorithm finishes. Jan 07 2010
Currently scopes objects can... Jan 08 2010
|