Re: Instance Variable access
Re: Instance Variable access
- Subject: Re: Instance Variable access
- From: Allan Odgaard <email@hidden>
- Date: Sat, 8 May 2004 18:16:46 +0200
On 8. May 2004, at 7:14, Andy Lee wrote:
(Note: I haven't done C++ in many moons, so the following comments
might be based on an outdated understanding of the language...)
[...] the messaging overhead of Objective-C is much closer to C++ than
to, say, Java.
For the records: C++ has two kinds of methods (called member
functions), by default a member function is just a regular function
which take an object pointer as a hidden first argument -- these can
easily be made inline by the compiler.
The other type is virtual member functions (there is no final keyword
in C++, this is from Java!) -- the compiler constructs a jump table
with all the virtual member function pointers for each class, and thus
a virtual member function is called by indexing this jump table and
jumping to the function -- these can rarely be made inline.
ObjectiveC uses the actual name of the method as signature/identifier.
When it needs to call a method it computes a hash from the name, looks
into a hash-table to see if a match is found, and if not, it finds the
method using the isa pointer (traversing linked lists of method names),
and then updates the hash.
Although the C++ standard does not require the implementor to use a
jump-table (often referred to as the vtable), the implementation
shouldn't come close to the complexity of ObjectiveC's obj_msgSend
(since C++ does not have open classes, categories, dynamic typing and
similar).
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.