Reset class member variables

Ingo Oeser ioe-news at rameria.de
Sun Sep 9 16:37:56 PDT 2007


Sean Kelly wrote:

> Nathan Reed wrote:
>> Using a new instance of the object for each iteration of the loop is
>> really what you're doing /conceptually/, anyway...so, I wouldn't worry
>> about the allocation performance too much unless you've profiled the app
>> and established that it is a bottleneck.
> 
> Or if there's some reason that the object must be re-initialized in
> place--say, to preserve its address.  One could argue that this
> necessity indicates a poor program design, but I imagine there are cases
> where it may apply.

Just to support Seans argument here...

One example from driver development: Some on-card descriptor, 
you get mapped via IO memory. The class would be your driver instance for
this card and your descriptor a struct or array member in that class.
You have to re-initialize that descriptor or at least part of after 
receive. One usually does that in some cleanup run for many at once.

Network Interface Cards (NICs) often work that way.


Best Regards

Ingo Oeser



More information about the Digitalmars-d mailing list