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

CPS invoke & return context

12 views
Skip to first unread message

Leopold Toetsch

unread,
Jun 28, 2003, 8:43:32 AM6/28/03
to P6I
In the meantime interpreter->warns has moved to the context structure
and gets now restored for CPS subroutine calls.

But there is a slight problem (as well as with e.g. pad_stacks)
When we have:

warningson 1
newsub .Sub, .Continuation, _func, _ret
...
invoke

and _func turns warnings off, the warns are restored fine.

When C<warningson> is after C<newsub>, the continuation has the old
state of warns. So we should update the continuation context at
C<invoke> time.

Here are some possibilities to achieve this:
- invokecc (this is slow)
- a new opcode e.g. C<updatecc> (update continuation ctx)
- toss invokecc's current functionality and use this opcode to update
the context and call the sub.

Comments welcome,
leo

Dan Sugalski

unread,
Jun 29, 2003, 3:11:31 PM6/29/03
to Leopold Toetsch, P6I

I like option 2. I'd also like to be able to manipulate the stacks in
a context, pushing things on them, changing values on them, and
generally messing about with the things, so I'm all for it.
--
Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
d...@sidhe.org have teddy bears and even
teddy bears get drunk

Leopold Toetsch

unread,
Jun 29, 2003, 5:19:44 PM6/29/03
to Dan Sugalski, P6I
Dan Sugalski wrote:
[ update continuation PMC at call time ]

>> Here are some possibilities to achieve this:
>> - invokecc (this is slow)
>> - a new opcode e.g. C<updatecc> (update continuation ctx)
>> - toss invokecc's current functionality and use this opcode to update
>> the context and call the sub.
>
>
> I like option 2.

Fine.

> ... I'd also like to be able to manipulate the stacks in a

> context, pushing things on them, changing values on them, and generally
> messing about with the things, so I'm all for it.

Do you have some examples for a usage of such manipulations? I thought
that a return continuations should exactly match the state of the
caller, so that the C<updatecc> op would do the work.
But there are for sure some hacks, that might need some:

updatecc <.stack> <.action> item


leo


Dan Sugalski

unread,
Jun 29, 2003, 7:14:49 PM6/29/03
to Leopold Toetsch, P6I
At 11:19 PM +0200 6/29/03, Leopold Toetsch wrote:

>Dan Sugalski wrote:
>>... I'd also like to be able to manipulate the stacks in a context,
>>pushing things on them, changing values on them, and generally
>>messing about with the things, so I'm all for it.
>
>Do you have some examples for a usage of such manipulations? I
>thought that a return continuations should exactly match the state
>of the caller, so that the C<updatecc> op would do the work.
>But there are for sure some hacks, that might need some:
>
> updatecc <.stack> <.action> item

Yep, that could work.

There are a few actual good reasons to do this:

*) A subroutine may want to affect the warnings state of its caller
*) A sub may want to add in block exit actions (though that's more an
inspection for the block exit item on the caller's stack)
*) It's possible the callee may want to mess around with an exception
handler at an outer level, though that's probably a bad idea
*) The callee may want to insert elements onto the control stack of the caller

Not *very* good reasons, mind, but... :)

Piers Cawley

unread,
Jun 30, 2003, 4:26:33 PM6/30/03
to Dan Sugalski, Leopold Toetsch, P6I
Dan Sugalski <d...@sidhe.org> writes:

> At 11:19 PM +0200 6/29/03, Leopold Toetsch wrote:
>>Dan Sugalski wrote:
>>> ... I'd also like to be able to manipulate the stacks in a context,
>>> pushing things on them, changing values on them, and generally
>>> messing about with the things, so I'm all for it.
>>
>> Do you have some examples for a usage of such manipulations? I
>> thought that a return continuations should exactly match the state
>> of the caller, so that the C<updatecc> op would do the work.
>>But there are for sure some hacks, that might need some:
>>
>> updatecc <.stack> <.action> item
>
> Yep, that could work.
>
> There are a few actual good reasons to do this:
>
> *) A subroutine may want to affect the warnings state of its caller
> *) A sub may want to add in block exit actions (though that's more an
> inspection for the block exit item on the caller's stack)
> *) It's possible the callee may want to mess around with an exception
> handler at an outer level, though that's probably a bad idea
> *) The callee may want to insert elements onto the control stack of
> the caller
>
> Not *very* good reasons, mind, but... :)

Yeah, but at least one of 'em is required in Perl 6 (the 'affect the
warnings state of the caller' thing) isn't it?

--
Piers

Dan Sugalski

unread,
Jun 30, 2003, 5:45:43 PM6/30/03
to Piers Cawley, Leopold Toetsch, P6I

Yup, and I want to be able to put lexicals in the calling scopes as
well, which we'll have to do to support the wacky MY stuff.

0 new messages