On Wed, Nov 23, 2005 at 03:14:40PM -0000, [EMAIL PROTECTED] wrote:
> implement Sub.get_caller() method; test
You keep confusing static and dynamic call information.
Like I've said (repeatedly :-)), rule #1 of call info is:
Subs don't have callers.
Call frames have callers.
Therefore, this code is not OK, because the Parrot_sub structure has
information it can't have:
> + METHOD PMC* get_caller() {
> + struct Parrot_sub * sub = PMC_sub(SELF);
> + PMC* cont, *sub_pmc;
> + cont = sub->ctx->current_cont;
> + sub_pmc = PMC_cont(cont)->to_ctx->current_sub;
> + return sub_pmc ? sub_pmc : PMCNULL;
> + }
Parrot_sub must not have a ctx member. Parrot_sub must have no
members which reflect dynamic calls, because with recursion you can
guarantee that there's no one correct answer for any dynamic query on
a Sub. (Continuations just make it worse.)
--
Chip Salzenberg <[EMAIL PROTECTED]>