discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why is this casting needed?


From: Günther Noack
Subject: Re: Why is this casting needed?
Date: Sat, 25 Mar 2006 12:51:51 +0100

Hi!

Am 25.03.2006 um 00:57 schrieb Adrian Robert:
But it's only a warning -- it still works at runtime in either case. What is the compiler doing differently with the cast? Is it some performance optimization?
The resulting code doesn't differ. When you pass a message to an object ("invoke a method"), the method implementation to be used is always dynamically looked up in the class tree. In old Objective-C implementations, there were no typed pointers to objects (everything was id). The typed pointers were added afterwards and so the errors the compiler emits about them are only intended to be a help for the programmer and won't ever stop compilation.

The reason why method implementations are looked up everytime is probably because the programmer can be allowed to make changes to the class hierarchy on runtime then.

-Günther





reply via email to

[Prev in Thread] Current Thread [Next in Thread]