in reply to Re: Inlining a "lexically-scoped scalar which has no other references"
in thread Inlining a "lexically-scoped scalar which has no other references"
I think it's an old optimization feature that got dropped/lost, without updating the docs.
If anyone has access to a fairly old perl5 version, it would be nice to know what these test produce... He doesn't need to use B::Concise, it's documented that redefining a "constant function" always has to give a warning!
so plz, just run this code, and check for a warning:
no warnings; my $lex = 4; # file scoped lexical #--- normal # inner scope sub with_proto () { my $lex } # outer scope { my $lex = 4; sub with_proto() { $lex } } # file scope sub with_proto() { $lex } #--- reference # inner scope sub with_proto() {\ my $lex } # outer scope { my $lex = 4; sub with_proto() {\ $lex } } # file scope sub with_proto() {\ $lex } #------ lvalue #--- normal # inner scope sub with_proto() :lvalue { my $lex } # outer scope { my $lex = 4; sub with_proto() :lvalue { $lex } } # file scope sub with_proto() :lvalue { $lex } #--- reference # lvalue references are not feasible, because of # "Can't modify single ref constructor in lvalue subroutine" #------ overriding constant function throws always a warning sub with_proto () {4} # uncommenting garanties a warning # sub with_proto () {5}
Cheers Rolf
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Inlining a "lexically-scoped scalar which has no other references"
by ikegami (Patriarch) on Sep 28, 2009 at 02:00 UTC | |
by ikegami (Patriarch) on Sep 28, 2009 at 02:09 UTC | |
by LanX (Saint) on Sep 28, 2009 at 02:21 UTC | |
by ikegami (Patriarch) on Sep 28, 2009 at 02:56 UTC |