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

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

by Perlbotics (Chancellor)
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2017-06-24 02:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (556 votes). Check out past polls.