develooper Front page | perl.perl5.porters | Postings from December 2021

Re: "no snails"; or having signatured subs complain about @_

Thread Previous | Thread Next
Paul "LeoNerd" Evans
December 9, 2021 17:36
Re: "no snails"; or having signatured subs complain about @_
Message ID:
On Thu, 9 Dec 2021 17:26:54 +0000
Dave Mitchell <> wrote:

> > OK, that's a detail I hadn't been aware of before. Keeping the
> > values on the stack does increase memory usage overall  
> No, because the values can be popped off the stack once assigning
> args to params is done. (Although, they'd have to be kept in the
> presence of 'perl -d' in order to keep caller() and @DB::args
> working).
> Once default argument expressions have started executing, all the
> args on the stack will have been consumed and are no longer needed.

This was the problem though - I couldn't work out how to keep @DB::args
working in that situation.

Also I still can't _quite_ picture how it would work. We have to
consume the arguments off the stack in a forward direction; we can't
work from the final argument and POPs them. I can't currently imagine
how each individual OP_ARGELEM op will know where it is supposed to be
looking on the stack.

Currently (from pp.c), pp_argelem encodes the index of @_ in its op_aux
pointer, so it can simply

    svp = av_fetch(defav, ix, FALSE);

In the "read directly from the stack" world, I can imagine it would

    svp = &PL_stack_base[ ??? ];

for some offset - how would it determine that?

Paul "LeoNerd" Evans      |  |

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About