The use of parenthesis around the parameter for return has no effect other than possibly to disambiguate the syntax. In other words, return 0; and return(0) will do the same thing.
| [reply] [d/l] [select] |
i think i started doing this out of some vague uneasiness about return handling scalars or lists. now that i think about it, it's pretty much a personal style thing at this point. which do you think is more appropriate?
| [reply] |
From perlsytle:
Along the same lines, just because you CAN omit parentheses in many places doesn't mean that you ought to:
return print reverse sort num values %array;
return print(reverse(sort num (values(%array))));
When in doubt, parenthesize. At the very least it will let some poor schmuck bounce on the % key in vi.
Even if you aren't in doubt, consider the mental welfare of the person who has to maintain the code after you, and who will probably put parentheses in the wrong place.
My rule of thumb is that if the syntax and meaning are perfectly clear without parenthesis, you can omit them. If leaving them out makes the code confusing, alters the outcome, or impedes readability, better include them.
| [reply] [d/l] |
I am using warnings in the main body of the code.
if I just use a plain return, it falls out at the return (generally). I am stepping through the code line by line and watching this happen. | [reply] |