Poll: a nonstate keyword

Janice Caron caron800 at googlemail.com
Sun Jun 1 06:31:12 PDT 2008


On 01/06/2008, Fawzi Mohamed <fmohamed at mac.com> wrote:
> but needs at least a mixin in the destructor, or there is some magic that I
> don't know yet?

There's some magic that you don't know about yet - specifically, that
classes are allowed to have multiple destructors. When the object goes
out of scope, all of its destructors are called. That means that the
Cache! mixin I mentioned earlier only needs to define an additional
destructor of its own.


> I think for example that in the case of lazy linked list the external
> hastable solution is probably too expensive, at leas twice as slow to
> traverse, and with at least twice the overhead in memory.

Absolutely. However, if the standard library were to provide List!(T),
then I think this need would go away.


>  Also for statistical information about calling pattern to a pure function
> one probably doesn't want to spend much time/space.

It might not be possible to collect "statistical information about
calling pattern to a pure function" anyway, since if the compiler does
any decent optimization, then the number of times that a pure function
is executed may have no bearing whatosever on the number of times that
it's called. I think, the question, "How often would it have been
executed if it wasn't pure?" can only be answered by not making it
pure!



More information about the Digitalmars-d mailing list