On Sun Oct 19 14:48:15 2014, mauke- wrote:
> On Sun Oct 19 07:04:15 2014, sprout wrote:> > On Sun Oct 19 01:46:40 2014, mauke- wrote:> > >> > > What's missing:> > > - newDEFSVOP (for generating the $_ in 'do_stuff_with($_) for> > > @values')> > > - intro_my (for declaring lexical variables)> > > - block_start (for opening a block)> > > - block_end (for closing a block)> > >> > > It would be nice if those functions (or an equivalent API) could be> > > made public.> >> > We usually don’t apify these without tests. Would you be willing to> > provide tests (using XS::APItest)?> > I don't know where to start with this. In fact, I'm not entirely sure> what those functions even do.
Well, that makes two of us. :-)
OK, I do know a bit more than that. block_start arranges for hints to be restored on block exit and also handles pad sequence numbers, to make sure ‘my’ variables go out of scope and that ‘my’ variables declared in the containing statement (e.g., my $x, do{...}) don’t accidentally become visible inside the block.
block_end is passed the return value of block_start (the savestack index) and the body of the block itself. It handles compile-time scope exit and returns the block, possibly modified. (Part of what it does is to call scalarseq on the body of the block, but I don’t understand what scalarseq does.)
intro_my is sufficiently described by its documentation in perlintern.pod:
"Introduce" my variables to visible status. This is called during parsing
at the end of each statement to make lexical variables visible to
subsequent statements.
> I basically just cargo-culted their> usage from what the perl compiler itself does. (And a test should> probably also include interesting corner cases - no idea what those> would look like here.)
Edge cases are icing on the cake. They are not necessary to get something into the API.
Some simplified code stolen from Function::Parameters would do.
--
Father Chrysostomos
---
via perlbug: queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=123009