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

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

Thread Previous
Paul "LeoNerd" Evans
November 29, 2021 18:14
Re: "no snails"; or having signatured subs complain about @_
Message ID:
On Mon, 29 Nov 2021 16:08:54 +0000
"Paul \"LeoNerd\" Evans" <> wrote:

> Far less clear is how to do parts 3 and 4. In particular, for part 3 I
> have the following thoughts on possible ways to implement it:

Oh I just thought of a 4th way:

  3d. Have pp_entersub perform much more of the work; effectively roll
      up the behaviours currently performed by OP_ARGCHECK and
      OP_ARGELEM into it. It would involve annotating the CV with some
      more metadata about its signature params - the counts and slurpy
      value (i.e. all the data stored by the OP_ARGCHECK op) and also
      the pad indexes of every recognised parameter. This could be used
      pp_entersub as well as any other metadata introspection abilities
      that might be added later.

      This would allow pp_entersub itself to copy elements out from the
      stack directly into the pad slots of the new CV, where the
      OP_ARGELEM ops would have put them. They'd go directly from stack
      into the pad, not via the @_ array then. Once there are no more
      argument values on the stack, any optional parameters that
      haven't yet got their values can be assigned them by jumping to
      the first OP_ARGDEFELEM op for a missing param.

      An upside is this would be even more efficient than all of the op
      calls down the optree per element. A downside however in that it's
      notably less flexible than the current setup. It would also
      totally break the way that Object::Pad's `method` keyword
      currently works - so I'd be somewhat in favour of not picking
      this approach. ;)

Paul "LeoNerd" Evans      |  |

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