in reply to Re: Hash (not) returned by subroutine
in thread Hash (not) returned by subroutine

> may give you a slight boost

Note that perl5200delta says:

In certain situations, when return is the last statement in a subroutine's main scope, it will be optimized out.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^3: Hash (not) returned by subroutine
by karlgoethebier (Abbot) on Jan 27, 2020 at 21:27 UTC
    "...certain situations...return...optimized out"

    Doesn’t such a method make the behavior of a programming language unpredictable? Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

    perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

      Doesn’t such a method make the behavior of a programming language unpredictable?

      Not if perl is sure that the situation allows optimizing out.

      I would blindly assume that all returns could be optimized out in this script:

      sub foo { # do something return; } sub bar { # do something return 'a scalar'; } sub baz { # do something return qw( a list ); } foo(); bar(); baz(); exit();

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)