Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Using constant to override (abstract) methods.

by moritz (Cardinal)
on Mar 28, 2011 at 08:40 UTC ( [id://895866]=note: print w/replies, xml ) Need Help??


in reply to Using constant to override (abstract) methods.

Now a colleague claims that I cannot rely on this behaviour because constants become *inline* functions and so the lookup might crash in some (unknown?) cases.

Not true.

The inliner does inline most "normal" calls to these subroutines, but since it can't catch every invocation (like soft references, method style invocations, goto &subname, maybe more...), it keeps the sub itself around.

So it means you can use the use constant-generated subs as methods reliably.

After all the inliner is just an optimization, and shouldn't change user-visible behavior.

Replies are listed 'Best First'.
Re^2: Using constant to override (abstract) methods.
by klekker (Pilgrim) on Mar 28, 2011 at 10:30 UTC
    Thank you for this helpful explanation!

    k

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-19 05:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found