in reply to Re^3: Label makes a sub to return empty list -- "secret"? documented?
in thread Label makes a sub to return empty list -- "secret"? documented?

well B::Deparse would fail then ...

There is also benefit in consistent behavior.

I'd rather prefer a second version of the sub construct (something like def ) which implements this, instead of relying on such syntax tricks.

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^5: Label makes a sub to return empty list -- "secret"? documented?
by Jenda (Abbot) on Sep 12, 2025 at 11:33 UTC

    Fail in what way? In not producing the exact (save for whitespace) copy of the original code? Is that really a problem? Both the compiled and "deparsed" code would still have to denote that the subroutine isn't returning the value of the statement before the empty return.

    Empty return is the only solution that is NOT a syntax trick, therefore it ought to be implemented efficiently and if B::Deparse needs to produce code of a subroutine that returns nothing, the empty return should be the "inferred" solution even if it means that deparsing turns some of those tricks into an explicit empty return.

    Jenda
    1984 was supposed to be a warning,
    not a manual!

      Yes probably.

      three issues worth mentioning:

      • a) Perl is not that orthogonal to be instantly sure these three variants always do the same thing.
      • b) P5P have bigger fish to fry than such micro optimizations.
      • c) maintaining B::Deparse is neither straightforward nor easy.

      Though if you think it's so important, you can submit a patch to optimize the last return away.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      see Wikisyntax for the Monastery