in reply to Re: Re: subroutines & functions
in thread subroutines & functions

I definitely don't care about the difference between returning a scalar or not returning anything, and most certainly not for "efficiency reasons": that extra test likely wastes more time

Um, if you are doing it for efficiency reasons, then you don't do all of the work and then, just at the end, check whether they want a value back or not. You note that they don't need a value back and avoid the whole computation. For example, in Win32::TieRegistry, you can use delete to delete a key/value from the registry. Just like when using delete on a regular hash, delete returns what the key (that was just deleted) contained. But if you use delete in a void context, then all of this making of copies is avoided.

Then there is the whole 'failures in a void context should resort to die' concept that I rather like.

                - tye
  • Comment on Re^3: subroutines & functions (wrong place)