Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^5: Prototypes required even after mocking a sub

by Anonymous Monk
on Sep 21, 2018 at 21:28 UTC ( [id://1222819]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Prototypes required even after mocking a sub
in thread Prototypes required even after mocking a sub

The post does not go through when I try to make that a link either using [] or html tags. I'm not sure I understand your question; Perl knows about it because you did it, and it checks for a mismatch in prototypes when that happens.

Replies are listed 'Best First'.
Re^6: Prototypes required even after mocking a sub
by stevieb (Canon) on Sep 21, 2018 at 21:35 UTC
    "The post does not go through when I try to make that a link either using [] or html tags"

    Fair enough. We do have a subset and mix of things here. [link_to_something|words to describe] is kind of backwards, but I digress.

    Getting to the point, I understand that perl knows about it, there's no question there. My question is *how* perl knows about the prototype(s), after I have effectively pissed all over the symtab entry for the sub.

    My question, more directly: Why and how does perl know that the sub I'm faking out (effectively), still keep reference to the prototypes that were involved in the subroutine I faked?

      It doesn't; as mentioned in the other thread it may compile against the original sub before it even gets to the prototype, as prototypes are used in the parsing phase. For example, the prototype ($) completely changes the meaning of this code: my @results = (foo 3, 5); If foo has a prototype of ($) then it will be executed as my @results = (foo(3), 5); rather than "slurping" up all the arguments available to it. This means that the parser constructs a completely different optree in this case. Overriding foo after that has been parsed doesn't change that.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1222819]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-03-28 20:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found