Invocation functions in src/extend.c

Andrew Whitworth wknight8111 at gmail.com
Sat Feb 21 18:55:44 UTC 2009


There are several functions in src/extend.c of the form
Parrot_call_method_ret_* or Parrot_call_sub_ret_*. These invoke a
Parrot sub with a given signature, and return a single typed data
item. As part of the ongoing calling conventions refactors, I would
like to unify these into only one or two functions, and pass return
values as pointers in the arglist instead. Here is an example of my
proposed change:

FLOATVAL f = Parrot_call_method_ret_float(interp, sub, obj, sub_name,
"PS", arg1, arg2);

This becomes:

FLOATVAL f;
Parrot_call_meth(interp, obj, sub, sub_name, "PS->F", arg1, arg2, &f);

And this, which is only a sub and not a method call:

INTVAL i = Parrot_call_sub_ret_int(interp, sub, sub_name, "SP", arg1, arg2);

could become either of these (depending on how aggressive we are about
unification):

INTVAL i;
Parrot_call_sub(interp, sub, sub_name, "SP->I", arg1, arg2, &i);

or

INTVAL i;
Parrot_call_method(interp, PMCNULL, sub, subname, "SP->I", arg1, arg2, &i);

This would also give us the power to return multiple values from a
Parrot subroutine in a single invocation instead of only a single
value, which does not currently appear to be possible from the current
extend interface. It would also eliminate reliance on the
Parrot_run_meth_* family of functions (from src/call/ops.c) which I'm
finding to be buggy, extraneous, and unnecessary.

Any thoughts on this? Any concerns about the extension interface that
this would break or improve?

--Andrew Whitworth


More information about the parrot-dev mailing list