[cfe-dev] Introducing attribute objc_pure_virtual_method

Erik Verbruggen erik.verbruggen at me.com
Wed Oct 30 13:59:17 PDT 2013


Also sending it to the list....

-- Erik


Begin forwarded message:

> From: Erik Verbruggen <erik.verbruggen at me.com>
> Date: 30 oktober 2013 21:57:54 CET
> To: David Chisnall <David.Chisnall at cl.cam.ac.uk>
> Subject: Re: [cfe-dev] Introducing attribute objc_pure_virtual_method
> 
> 
> -- Erik
> 
>>> On 30 okt. 2013, at 15:24, David Chisnall <David.Chisnall at cl.cam.ac.uk> wrote:
>>> 
>>> On 30 Oct 2013, at 08:53, Jean-Daniel Dupas <devlists at shadowlab.org> wrote:
>>> 
>>> My 2 cents (even if the feature does not end up in clang).
>>> The concept of "pure virtual" may be clear for people common from C++, but I dont think this is the right wording to choose for Objective-C.
>>> The Apple documentation never ever mentions the term virtual once for objective-c.  I think the word commonly used is "abstract" so a better name for this attribute could be objc_abstract_method .
>> 
>> And even that is quite rare.  A more common notion in Objective-C is a primitive method (e.g. -length and -characterAtIndex: in NSString), which is then used to implement all of the others and must be implemented in subclasses.
>> 
>> It would be interesting to have a language feature that can check these (and make them more obvious - I've seen numerous instances of people skim-reading documentation and not identifying all of the methods that they must implement).  It would be cleaner, from a documentation standpoint, to be able to mark a protocol that a class implemented as requiring reimplementation in all subclasses.  Then it could be something that was both obvious in the documentation and checkable in the compiler.
> 
> Maybe off-topic, or maybe I'm interpreting it wrong, but this looks like warning when -hash or -equals are not defined for a class. I would love to have this, as it's a common pitfall in multiple languages (Java comes to mind), but I can't come up with a good heuristic  that won't have many programmers pull their hair out because of compiler complaints. However, that might be my lack of imagination. 
> 
> For class clusters: although I think it's a really cool concept, I'm not sure if it's useful/effective to cater for it. There are very, very few programmers who implement them, and when they do, they tend to know exactly what the implications are and what's going on. That said, a warning indicating that a certain method should be considered for overwriting is vey useful and would catch this case (well, everybody compiles with -Werror, right?)...
> 
> -- Erik.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131030/15e8cac0/attachment.html>


More information about the cfe-dev mailing list