Are scope class useful ?

bearophile bearophileHUGS at lycos.com
Thu Jan 7 18:17:47 PST 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.

Currently scopes objects can be useful as a performance optimization too. They (when possible) get allocated on the stack, and avoiding heap allocations in D is currently very advantageous because the GC is currently slow (compared to modern GCs you can find in Java).

And time ago I've said to LDC developers that there is another way to further optimize the deallocation of such stack-allocated objects (improving the deallocation code), so in future their performance will hopefully further improve a little.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list