[cfe-dev] Introducing attribute objc_pure_virtual_method

David Chisnall David.Chisnall at cl.cam.ac.uk
Wed Oct 30 07:24:21 PDT 2013


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.

David





More information about the cfe-dev mailing list