in reply to References for ano subs fixed at compile time?
If a sub doesn't close over any lexicals, than I bet that refs to it will be constant. If subs close over lexicals (or represent different code), than the refs can't be constant unless the refs have non-overlapping lifespans.
DB> sub test(&) { my( $c ) = @_; print 0+$c,$/; return $c } DB> ;{ my($a,$b); test {$a}; test {$b} } 14808916 14808916 DB> ;{ my($a,$b); my $c = test {$a}; test {$b} } 15512116 15512804 DB> ;{ my @a; for(1..3){ my $a; push @a, test {$a} } } 15513028 15511044 15513252
- tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: References for ano subs fixed at compile time? (nope)
by LanX (Saint) on Jun 18, 2013 at 21:36 UTC | |
by tye (Sage) on Jun 18, 2013 at 22:06 UTC | |
by LanX (Saint) on Jun 18, 2013 at 22:14 UTC | |
by tye (Sage) on Jun 18, 2013 at 22:59 UTC | |
by LanX (Saint) on Jun 19, 2013 at 00:30 UTC |