Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Partial fix to make closures invoke actions

0 views
Skip to first unread message

Bob Rogers

unread,
Jul 26, 2006, 9:49:07 PM7/26/06
to parrot-...@perl.org
I've been toying with this patch for a week now, because I'm not sure
whether I should apply it. I think it's a step forward, but it doesn't
solve the whole problem, and might be premature.

What it does:

1. Defines Parrot_rewind_stack as a stub for a more general
implementation of stack rewinding.

2. Changes Continuation:invoke to use it. This makes closure
invocation run all actions in leaving contexts (a bug I would like to
see fixed).

3. Fixes two test cases in t/pmc/exception.t that appear to expect
actions to be thrown away when calling a closure. (Are these just
oversights, or does someone actually need the current behavior?)

4. Removes $TODO from another t/pmc/exception.t case that now
works.

5. Adds three cases to t/pmc/continuation.t, one showing that the
change works (probably redundant wrt the previous case, now that I think
of it), and two more showing its limitations.

Problems:

1. It doesn't invoke the actions in the right dynamic environment.
This is largely because "the current dynamic environment" is tied into
"the currently-executing sub", rather than being stored in the
interpreter and captured by continuations. But fixing that is a much
larger job, which (I assume) we are not yet ready to tackle.

2. Parrot_rewind_stack uses stack_height, which makes it linear in
the current stack depth, rather than linear in the number of entries
that must be traversed. This could be fixed with a bit more effort, but
is only a matter of efficiency.

Possible actions:

1. Apply now, and worry about doing it right when rewinding is
better defined.

2. Punt until then.

3. Start working on a more comprehensive fix.

Opinions?

-- Bob Rogers
http://rgrjr.dyndns.org/

closure-cleanup-3.patch
0 new messages