<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Nov 29, 2010, at 4:09 PM, Stuart Carnie wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><font face="tahoma,sans-serif">Hi all,</font><div><font face="tahoma,sans-serif"><br></font></div><div><font face="tahoma,sans-serif">I would like to have a go at hacking a little on Clang when a get a bit of spare time, and have found that adding support for override would be useful little exercise.  I've seen another post referring to Clang's support for __attribute__((override)), and seems like I could use this as a starting point.</font></div>
<div><font face="tahoma,sans-serif"><br></font></div><div><font face="tahoma,sans-serif"><a href="http://weblog.bignerdranch.com/?p=171">Big Nerd Ranch</a> would like to see an @override keyword, as follows:</font></div><div>
<font face="tahoma,sans-serif"><br></font></div><div><font face="tahoma,sans-serif"><span class="Apple-style-span" style="font-family: Verdana, Tahoma, Arial, sans-serif; font-size: 12px; color: rgb(48, 48, 48); line-height: 19px; "><pre class="code" style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; font-family: Courier; font-size: 1.2em; width: 672px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-width: initial; border-color: initial; border-top-width: thin; border-right-width: thin; border-bottom-width: thin; border-left-width: thin; ">@override
- (NSInteger)numberOfSectionsInTableview:(UITableView *)tv
{ ... }</pre></span></font></div><div><font face="tahoma,sans-serif"><br></font></div><div><font face="tahoma,sans-serif">This would seem the most natural, but I feel it would involve mucking with the parser, the AST and therefore fairly complicated.  Given Clang already parses __attribute__, I could take the following approach instead:</font></div>
<div><font face="tahoma,sans-serif"><br></font></div><div><font class="Apple-style-span" face="tahoma, sans-serif"><span class="Apple-style-span" style="font-family: Verdana, Tahoma, Arial, sans-serif; font-size: 12px; color: rgb(48, 48, 48); line-height: 19px; "><pre class="code" style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; font-family: Courier; font-size: 1.2em; width: 672px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-width: initial; border-color: initial; border-top-width: thin; border-right-width: thin; border-bottom-width: thin; border-left-width: thin; position: static; z-index: auto; ">- (NSInteger)numberOfSectionsInTableview:(UITableView *)tv __attribute__((override))
{ ... }</pre></span></font></div><div><font class="Apple-style-span" face="tahoma, sans-serif"><br></font></div></blockquote><div><br></div>attribute is preferred but, first you need to implement it for .cpp (as it is intended for), and then see if it makes sense to do same for</div><div>an objc method. I don't know its c++ semantics so I cannot make any comment on its usefulness for objc methods.</div><div><br></div><div>- Fariborz</div><div><br></div><br></body></html>