<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">On Oct 29, 2013, at 3:16 PM, variadictemplate . <<a href="mailto:variadic.template@googlemail.com">variadic.template@googlemail.com</a>> wrote:<br><div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-family: HelveticaNeue; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">currently there is no possibility in objective-c to mark a method as "pure virtual" like in C++. I think the "pure-virtual"-construct enables an elegant and clean way to describe and specify APIs, although if it may be a rarely used construct.</div><div style="font-family: HelveticaNeue; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">A workaround for objective-c is to declare the method within the base-class and add to it's implementation an assertion like assert(false && "has to be implemented by subclasses"). But i think it would be nicer when the compiler gives me a hint that there is something wrong, instead of crashing the app at runtime.</div><div style="font-family: HelveticaNeue; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br></div><div style="font-family: HelveticaNeue; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">So, with my attached patch I'm introducing an attribute for that case, named objc_pure_virtual_method. It can only be attached to methods of a class-declaration (the other way round: extensions, categories and protocols are excluded). If a subclass does not implement the method, it will cause a warning. If the subclass redeclares the method within it's @interface-declaration and also adds the objc_pure_virtual_method, no warning will be generated. If the call of an init-method to an instance of a class with pure virtual methods is detected, an error is generated.</div><div style="font-family: HelveticaNeue; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br></div><div style="font-family: HelveticaNeue; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">I'm not sure if the init-call to a subclass of an abstract class, that did not implement all pure virtual methods, should also produce an error, as this case already produces warnings of unimplemented methods - in my eyes, this is sufficient.</div><div style="font-family: HelveticaNeue; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br></div><div style="font-family: HelveticaNeue; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Surely there are some issues with my current implementation, as i'm not so sure if i have chosen the right places to add the logic and about the names / warnings i have chosen and I'm happy to hear any suggestion / <a href="http://www.dict.cc/englisch-deutsch/criticism.html" style="font-size: 13px; text-decoration: none; font-family: arial, helvetica, sans-serif;">criticism</a>.</div></blockquote></div><div><br></div><div>Hi there,</div><br><div>I think this an interesting direction to explore. I have a few concerns about the model, as it doesn’t feel quite there yet.</div><div><br></div><div>(1) If a method is marked virtual in a class, should there be a warning to implement that method in the same class?</div><div><br></div><div>(2) In a subclass, if a method is redeclared as being “non-virtual”, should we also guarantee that it is implemented in the @implementation? That may be tricky of course with categories.</div><div><br></div><div>It also seems like we should exclude this attribute to being applied to certain method families, such as “init”, as there are other idioms at play there.</div><div><br></div><div>Minor nit:</div><div><br></div><div> “classdeclaration”</div><div><br></div><div>For clarity (and to fix the typo), just say “class’s @interface"</div><div><br></div><div>Once we resolve some of these questions, I’d also like to discuss this with a few others off list (particularly framework authors), as this is essentially a language change.</div><div><br></div><div>Cheers,</div><div>Ted</div></body></html>