[cfe-dev] Even more clang ideas

Chris Hanson cmh at me.com
Sun Aug 3 22:11:28 PDT 2008


On Aug 3, 2008, at 3:52 PM, John Engelhart wrote:

>> In fact, in Objective-C it is not possible to say "this method
>> returns an instance of specifically this class and no other class"
>> -- you can only say "this method returns an instance of this class   
>> or any subclass."
>
> I disagree.  Such things were possible in older compilers because of
> pointer rules.  Type punning was always frowned upon, and is now
> strictly forbidden in C99.  Except for 'union's, C doesn't really
> provide a means for multi-type pointer representations.  It's not
> really a question of what proper OO design paradigm is, it's a
> question of "where the rubber meets the road": How do you represent
> the concept in C.

It doesn't matter how the concept is represented in C, because modern  
Objective-C compilers are *not* simple translators from Objective-C to  
C; they must treat the language as a language in its own right,  
because it does add additional semantics atop C.

First and foremost an Objective-C compiler must understand and  
preserve the semantics of the Objective-C language -- which includes  
proper handling of subtype relationships within the class hierarchy.

   -- Chris




More information about the cfe-dev mailing list