Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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

by Perlbotics (Abbot)
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 perusing the Monastery: (10)
As of 2014-04-20 14:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls