Feature Request: Change the delegate type to void[] data insteadofvoid*ptr.
BCS
ao at pathlink.com
Thu Oct 4 21:57:51 PDT 2007
Reply to Downs,
> Yes.
> The idea is, since chained indirection only accesses consecutive stack
> frames anyway, void[] data contains _all_ the *outer* stack frames
my assertion is that, in general, the outer stack frames are *NOT consecutive*
consider this code:
|Foo(void delegate() dg)
|{
| dg();
|}
|
|void Bar()
|{
| int i;
| Foo({
| int j;
| Foo({
| int k;
| Foo({
| int l;
| Foo({
| int m;
| Foo({
| int n = 1;
| Foo({
| i += j += k += l += m += n;
| });
| });
| });
| });
| });
| });
|}
when the most nested delegate gets called it accesses six non-consecutive
stack frames (Bar calls Foo calls delegate calls Foo ..., each delegate stack
frame is seperated by a Foo stack frame) If the code for Foo is not known
at compile time then their is no way to know where the outer stack frames
are short of looking through a chain of pointers.
To better illustrate this consider where Foo is this:
|Foo(void delegate() dg)
|{
| dg();
| int
| dg();
|}
with the second call in Foo, the offset of the called stack frame (the next
more nested delegate) to the calling stack frame (the next delegate out)
is different than for the first call. Without knowing which time you are
being called you can't find the outer stack frames without a pointer chain
to them.
> The stack space of other passed-in functions is not directly
> accessible from the current function.
I don't follow that. It looks like I must have been unclear with what I was
saying. The above section reiterates what I was trying to say.
> --downs
>
More information about the Digitalmars-d
mailing list