Here's a few reasons I don't like this:
- I can't return anything but errors
(For one thing, I like to assign a meaningful variable name to the output to help explain the purpose of the subroutine)
- The truth value of a subroutine is counter intuitive (The opposite of perl's built-in functions)
- I still have the unreadability of mixing lots of technical error gunk with procedural code.
Thanks for the suggestion anyway :) | [reply] |
Well, I voted you up, for your entry adds some food for thought, but I disagree. Returning 0 on success and an error code in case of failure, that's what the shell works. In a a shell script, you mostly run commands for what they give you on the standard output, which you can pipe into other commands. The return value is merely a side effect, that can only cary a number, and that is perfect for error reporting. To this effect, the truth in Shell is the opposite as in Perl: 0 is true, while everything else is false.
If you want to do the same in Perl, you'd have to cram ! everywhere, which IMHO does not participate to the legibility of your code. And you deprive yourself of the ability of returning a wealth of data, scalars, lists, references from functions.
--bwana147
| [reply] |