Reset class member variables
dennis luehring
dl.soluz at gmx.net
Fri Sep 7 12:39:59 PDT 2007
> (btw: the need of reseting an object could be a design problem)
examples:
1# bad example:
int result[];
auto obj = new TheObject();
for( ... )
{
result ~= obj.do_some_thing( some_data );
obj.reset();
}
possible errors: you forgot the .reset() or the reset isn't correct
implemented
....
2# better, cleaner way:
int result[];
for( ... )
{
auto obj = new TheObject();
result ~= obj.do_some_thing( some_data );
}
in this case you don't have to safe/repair your object state
possible errors: none
--- design blabla
the obj.reset is (maybe) an hard optimizing step (if the newing IS
expensive) or your obj is doing the wrong stuff (in the wrong context?)
More information about the Digitalmars-d
mailing list