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

[perl #22745] [PATCH] Parrot subroutines

12 views
Skip to first unread message

Jonathan Sillito

unread,
Jun 20, 2003, 12:48:31 PM6/20/03
to perl6-i...@perl.org, bugs-bi...@netlabs.develooper.com
The patch looks pretty good to me. Here is a proposal for an alternative
inheritance hierarchy. Invocable, the root of the hierarchy, is basically a
sub that is not a closure (i.e. *no* context at all, just an address).

pmclass Invocable { # I called this sublite before
/* SELF->data is always NULL */
/* SELF->cache.int_val holds address */

void set_integer_native(INTVAL value) {
SELF->cache.int_val = value;
}
void* invoke() {
return (void*)SELF->cache.int_value;
}

...
}

pmclass Sub extends Invocable {
/* SELF->data is a lex_pad (or stack as Leo suggests) */
}

pmclass Continuation extends Invocable {
/* SELF->data is a pointer to a Parrot_Context struct */
}

pmclass Coroutine extends Continuation {...} /* maybe ??? */

In the current implementation there is a difference between the sub pmc and
the struct Parrot_Sub. The same goes for continuations and coroutines. The
above suggests that we could merge those together and just have the pmc
versions.

--
Jonathan Sillito

Matt Fowles

unread,
Jun 20, 2003, 3:26:52 PM6/20/03
to Jonathan Sillito, perl6-i...@perl.org, bugs-bi...@netlabs.develooper.com
All~

Jonathan Sillito wrote:
> The patch looks pretty good to me. Here is a proposal for an alternative
> inheritance hierarchy. Invocable, the root of the hierarchy, is basically a
> sub that is not a closure (i.e. *no* context at all, just an address).
>
> pmclass Invocable { # I called this sublite before
> /* SELF->data is always NULL */
> /* SELF->cache.int_val holds address */
>
> void set_integer_native(INTVAL value) {
> SELF->cache.int_val = value;
> }
> void* invoke() {
> return (void*)SELF->cache.int_value;
> }
>
> ...
> }
>
> pmclass Sub extends Invocable {
> /* SELF->data is a lex_pad (or stack as Leo suggests) */
> }
>
> pmclass Continuation extends Invocable {
> /* SELF->data is a pointer to a Parrot_Context struct */
> }
>
> pmclass Coroutine extends Continuation {...} /* maybe ??? */
>

Might I suggest:

Sub as the base class
Closure for what you call Sub
Continuation and Coroutine as the same.


These names seem to hold closer to what they are strictly speaking.

Matt

0 new messages