develooper Front page | perl.perl5.porters | Postings from January 2018

Re: [perl #132768] OP_ENTERSUB is not called for constructor of tiedobject

Thread Previous | Thread Next
January 28, 2018 13:04
Re: [perl #132768] OP_ENTERSUB is not called for constructor of tiedobject
Message ID:
KES wrote:
>When we tie scalar to 'MyObj' class the MyObj::TIESCALAR is called
>but OP_ENTERSUB is not executed before that. 

Not a bug.  There is no entersub op because the sub call is not being
made from Perl code.  There are many places in which subs get called by
means other than explicit calls from Perl code.  Any XS code can make
a sub call, and we even have a whole documentation file advising XS
programmers how to do that.  It is not remotely viable to rely on sub
calls being made only through Perl ops.

>But still we can see OP_LEAVESUB for it

The leavesub op isn't part of the call site, it's part of the called sub.
Of course it only exists for a called Perl sub.  You'll see the opposite
pattern when calling an XS sub explicitly from Perl code: an entersub
op at the call site, then no leavesub or any other op until control has
returned to the call site and moved on to the next thing.


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