Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^3: my $cache = undef if undef;

by Aristotle (Chancellor)
on Jan 26, 2005 at 17:48 UTC ( #425313=note: print w/replies, xml ) Need Help??

in reply to Re^2: my $cache = undef if undef;
in thread my $cache = undef if undef;

It cannot be clobbered, and there are no memory leaks in either case. It's an effect of how the pads for lexical variables are maintained by the Perl core. Larry didn't want to promise this will always work, but it's very unlikely to break, since it's kind of an accidental feature of the Perl guts architecture. A lot would have to change to break it.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re^4: my $cache = undef if undef;
by ysth (Canon) on Jan 27, 2005 at 06:32 UTC
    It may very well be gone someday in perl5. Really. Don't use it. Also note that the staticness is relative to the pad, not the function; for instance, the data does not persist for recursive calls to the function.

      If you look a few nodes further up the thread you'll see I'm advising against its use anyway. :-) I'm simply saying that there is a lot of inertia against its disappearance. That's not a promise, of course. It does work in the meantime though, and can very occasionally be useful so long as we're talking about throwaway code (I used it in a oneliner once to save a few keystrokes.)

      Makeshifts last the longest.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://425313]
NodeReaper serves mincemeat tarts with the cider

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2018-06-23 20:01 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.