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

Re: Reference to a non-primitive (e.g. hash) local function variable is returned to the caller

by Perlbotics (Canon)
on Sep 21, 2011 at 09:46 UTC ( #927115=note: print w/ replies, xml ) Need Help??


in reply to Reference to a non-primitive (e.g. hash) local function variable is returned to the caller

Short: It's possible and legal.

It's non best-practice programming for languages like C, C++, etc. where returning pointer to object from the stack is an error. But this is Perl and Perl usually keeps track of the variables in use (ref-counts) and garbage collects them when necessary.
There are edge-cases with cyclic dependencies though (see: weaken in Scalar::Util).


Comment on Re: Reference to a non-primitive (e.g. hash) local function variable is returned to the caller

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (14)
As of 2015-07-29 14:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls