To paren, or not to paren, that is the question
Joe Hebert
Posts: 2,159
I’m reading thru someone else’s code and I see a bunch of functions that require no parameters that are defined like this:
I’ve always done it this way regardless of the existence of parameters:
I didn’t know the parens were optional. Do you drop the parens if you declare a function with no parameters? It just looks wrong to me but maybe it’s just me. Curious what the standard is…
DEFINE_FUNCTION aFunction { }
I’ve always done it this way regardless of the existence of parameters:
DEFINE_FUNCTION aFunction() { }
I didn’t know the parens were optional. Do you drop the parens if you declare a function with no parameters? It just looks wrong to me but maybe it’s just me. Curious what the standard is…
0
Comments
define_function beHappy:){
}
In PERL you can either have them or not as well. I think if you use empty parentheses, it says that you thought about the parameters, and decided there should be none. Without them, you don't know if they should be no parameters or the programmer just forgot. Plus if you use them and then need to add parameters later, a find and replace is easy from () to (integer idx). Otherwise its impossible and would have to be done by hand.
Paul