Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 browsing the Monastery: (12)
As of 2015-09-01 19:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred temperature scale is:










    Results (43 votes), past polls