Safer casts

Yigal Chripun yigal100 at gmail.com
Sun May 11 14:53:13 PDT 2008


your reply is correct but it is misleading.
a different example:
void Fn() {
  int i;
}

every time the function is called a new int i is generated on the stack
and destroyed when the function is exited. so for a specific call to Fn
there can be only one variable i, in the course of the program that same
variable is created and destroyed many times ( for each call to the
function).
you are correct in saying that there is only one mysort function but
every time you call it with a different comp delegate it needs to have a
different sort instance. the difference is that the int i is generated
on the stack but all those different sort instances are not. those are
code which goes into the executable.
so while in any specific time mysort uses only one sort instance, over
the course of the entire program the sort template can get instantiated
more than once.
does it make more sense to you, now?

--Yigal



More information about the Digitalmars-d mailing list