Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Difference between function and message

Difference between function and message
Thread Tools
Fresh-Faced Recruit
Join Date: Apr 2001
Location: Murray, Utah, USA
Status: Offline
Reply With Quote
May 23, 2001, 10:25 AM
 
After reading the OOP and the Obj-C Language book from ADC I have a question regarding messages vs. function calls: what is the reaction time?

A function executes NOW. In C++, if I do:

myObject->myFunctionCall();

it executes before anything after it does. However, from all my past coding experience, a message is sent (via FIFO) to an object and is handled when the object "gets to it". So:

[myObject myFunctionCall];

could execute much later than its C++ counterpart. Is this true in Objective-C? or am I missing a piece of the puzzle?

Thanks,
Jeff
     
Dedicated MacNNer
Join Date: Jan 2001
Location: Virginia, US
Status: Offline
Reply With Quote
May 23, 2001, 12:49 PM
 
There's no FIFO queue, or anything like that.

With every ObjC call, the message name is used to do a lookup on the receiver's class to find the corresponding implementation (a C function really), and then calls that function. This is called "dynamic binding", where the function to be called is determined at runtime instead of at compile time ("static binding").

The use of dynamic binding does actually open up a world of new possibilities, but in the typical case your method just gets called as normal.

     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 03:13 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2