in reply to How to enforce void context in Reply?

I'm fascinated by this question.

What would be a reason to desire to enforce a void context for a Perl subroutine return value?

  • Comment on Re: How to enforce void context in Reply?

Replies are listed 'Best First'.
Re^2: How to enforce void context in Reply?
by Anonymous Monk on May 19, 2015 at 10:40 UTC

    As noted in wantarray:

    return unless defined wantarray; # don't bother doing more my @a = complex_calculation(); return wantarray ? @a : "@a";

    Perhaps the OP is using a function that uses that strategy.

      That is detection not enforcement ... language barrier?

        If there is a sub foo that uses the above method of detecting when it is called in void context so that it can do less work; then that would be a reason the caller of sub foo (docdurdee) might want to enforce void context on it.