Aaron Sherman wrote:
On Mon, 2004-10-18 at 07:55, Sam Ruby wrote:

I've been trying to make sense of Python's scoping in the context
of Parrot, and posted a few thoughts on my weblog:

http://www.intertwingly.net/blog/2004/10/18/Python-Parrot-and-Lexical-Scopes

It seems like everything on that page boils down to: all functions are module-scoped closures.

A closer translation: "How do I implement module-scoped closures in Parrot?"

Your example: [snip]

Is also useful for context, but I don't think you need the Perl translation to explain it.

You elided the reason why I included it:

Suggestions welcome, in particular, a PIR equivalent to the Perl
would be most helpful.

If I look at the description of the scratchpad opcodes, I don't see all the pieces that I need (save_context, restore_context, mark_context, swap_context, etc). However, by poking around enough, and with a little bit of dumb luck, I have stumbled across src/sub.c.

The functions it defines aren't used by any opcodes, but are used by a
few PMCs.  Those PMCs have delightful names like continuation,
coroutine, and retcontinuation.  So the prefered approach is either use
one of these, or package the desired functionality into a pyfunction.pmc?

Unfortunately, these PMCs don't seem to have test cases.

Clearly, I'm fumbling around in the dark.  A well placed RTFM (including
an indication of *which* FM) would be most welcome.  Until then, I will
continue to ask questions, make observations, and submit patches to
bring the code base in line of where I'm guessing it wants to go - even
if many or most of these get rejected.

- Sam Ruby

Reply via email to