Re: Programming Style: Method Definition with or without a semicolon.
Re: Programming Style: Method Definition with or without a semicolon.
- Subject: Re: Programming Style: Method Definition with or without a semicolon.
- From: Andy Lee <email@hidden>
- Date: Fri, 16 Oct 2009 09:37:40 -0400
On Oct 16, 2009, at 3:55 AM, Bill Bumgarner wrote:
I haven't booted my NS 0.8 cube in about a decade, but I'm pretty
sure the semi-colon was always required in the header file and
always allowed in the @implementation.
'Twas many a moon ago, but, I do distinctly remember triple-clicking
method declarations from headers (with semis) to copy-paste into my
implementation without deleting the semi. It always stuck with me
as an über-convenience.
I too had the feeling this feature had been around forever, or at
least a pretty long time, possibly as far back as the NeXT days.
I don't like it because:
* It's jarring to see the semicolon used as a terminator in the method
declaration and as something else -- I'm not sure what; a superfluous
separator? -- in the definition where the line of code is otherwise
identical.
* I sometimes look for method overrides in my project by doing a
global search for ")myMethod" (trusting myself to be consistent about
having no space between the return type and the method name). If both
the declaration and the definition use the line "(void)myMethod;", it
takes slightly more effort to distinguish the declarations from the
definitions in the search results. Sure, I could address this by
putting the opening brace on the same line, but I strongly prefer the
method's opening brace on its own line.
* I'm paranoid about getting used to the pattern
blah blah blah;
{
etc etc
}
...because it might make it easier to overlook a bug like:
if ([they respondsToSelector:@selector(didStartItFirst)] && [(id)
they didStartItFirst]);
{
[self startThermonuclearWar];
}
--Andy
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden