in reply to Re^2: How to enforce void context in Reply?
in thread How to enforce void context in Reply?

That is detection not enforcement ... language barrier?
  • Comment on Re^3: How to enforce void context in Reply?

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

    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.

      But doesn't just calling  foo() in void context
          foo();
      enforce void context upon the invocation of foo()? What need for anything else?

      Is it ever possible to get a value directly returned from a subroutine invoked in void context, whether "enforced" or "natural" (as in the example above)? (Of course, it's always possible to indirectly return values from subroutines invoked in void context.)


      Give a man a fish:  <%-(-(-(-<

        What need for anything else?

        True, but it can still happen by accident that a sub is executed in non-void context when the programmer wanted it in void context, as shown above in sub calls_it_1. Also docdurdee mentioned a REPL, so my guess would be that the REPL puts every line entered at the prompt into some non-void context.