This brings up a couple of issues:
1. For purposes of error checking, Parrot obviously considers that
tailcall passes arguments, as for function calls, even when tail-calling
a continuation in order to effect a return. Should continuations be
handled specially, or do we want to define that "tailcall" always means
"call"?
2. Passing the sub args to a tail-called sub/continuation strikes me
as buggy, but I can't think of a way to fix this without breaking the
"feature" that it is currently possible to call get_params multiple
times. One such fix is attached. It works by having parrot_pass_args
"use up" the args and params in the PARROT_OP_get_params_pc case. Doing
this for the other cases doesn't seem to break anything else, and
strikes me as a good idea; should I make it happen for all
parrot_pass_args calls?
Alternatively, passing the sub args could be defined as expected
behavior, but that seems error-prone.
If I hear no objections to flushing "multiple get_params" (nor
exhortations to generalize "using up" the args), I will commit the patch
as-is.
-- Bob Rogers
http://rgrjr.dyndns.org/
>
> If I hear no objections to flushing "multiple get_params" (nor
> exhortations to generalize "using up" the args), I will commit the
> patch
> as-is.
Multiple get_params don't work with tailcalls as the caller's frame
(with the args inside) is reused by the tailcalled sub (more precisely:
the get_param of a tailcall frees the callers's frame). Therefore this
patch is ok.
That is we have to mandate that there is exactly one get_params as the
first opcode of a sub (currently no get_params is issued for void subs,
but that will change to enable param count checks for that case too).
leo