To paren, or not to paren, that is the question
Joe Hebert
Junior Member
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…
Comments
-
Hmmm, never came across that either and I agree it just looks wrong. I would stay with ().
-
When code goes bad that's the first question that always gets asked. "Where were the parens?"
-
That doesn't work in any if the other development environments I'm aware of. But heck, Axcess used to let you get away with murder. I'm probably the other end of the spectrum. I use more parentheses and curly braces than necessary. It just helps me visually
-
If only for clarity reading it later, I would include the empty parentheses.
-
This would be nice...
define_function beHappy:){
} -
ericmedley wrote: »That doesn't work in any if the other development environments I'm aware of. But heck, Axcess used to let you get away with murder. I'm probably the other end of the spectrum. I use more parentheses and curly braces than necessary. It just helps me visually
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
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums
