• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Returning a value from a function
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Returning a value from a function


  • Subject: Re: Returning a value from a function
  • From: Alastair Houghton <email@hidden>
  • Date: Tue, 8 Apr 2008 14:00:40 +0100

On 8 Apr 2008, at 13:20, Jason Stephenson wrote:

I. Savant wrote:
No, it's precisely accurate. While the meaning is clear in this case, failure to use proper terminology on a technical mailing list can cause confusion resulting in more noise and wasted time. A method is a method. A function is a function.

A method is simply a subclass of function, it being a functional member of an object. While I agree that saying method in this case is more precise than function, using the term function is still accurate.

Well... what you say is true to an extent, but in Objective-C parlance a method is rather more than just a function. For instance, ObjC methods are registered with the runtime and have type information and a name (the selector). They are also invoked by sending messages rather than by making function calls; it so happens that the ObjC runtime implements local message sends using function calls, but it's quite possible to send arbitrary messages to remote objects. Even for local messages, a message send takes a different amount of time to a function call (mostly because it needs to look up the method in the object's method list; there is, of course, a per-object cache to speed this up).


Additionally, ObjC methods can be added or removed at runtime, or even "swizzled" (by replacing the function pointers in an object's method table), none of which is possible with ordinary functions.

Methods and function calls are not nearly as similar in ObjC as they are in C++.

Drawing distinctions in cases where they are not needed is also a waste of time. As three of us have now wasted our time on this semantic discussion. ;)

Make that four.

I agree with I. Savant and Mike Abdullah on this. It's best not to muddle your terminology. You may not think you care, but muddle- headedness will manifest itself sooner or later in your code (or in a daft post to the mailing list---e.g. asking why you can't use "&" to take the address of a method, the answer being that it *isn't* a function), and then you'll wish you had.

There's no reason to be imprecise, and there are good reasons not to be.

Kind regards,

Alastair.

--
http://alastairs-place.net


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Returning a value from a function (From: Stuart Green <email@hidden>)
 >Re: Returning a value from a function (From: Bryan Henry <email@hidden>)
 >Re: Returning a value from a function (From: Mike Abdullah <email@hidden>)
 >Re: Returning a value from a function (From: Bryan Henry <email@hidden>)
 >Re: Returning a value from a function (From: "I. Savant" <email@hidden>)
 >Re: Returning a value from a function (From: Jason Stephenson <email@hidden>)

  • Prev by Date: Re: How to add number do Dock Icon like in Mail?
  • Next by Date: Returning a value from a function
  • Previous by thread: Re: Returning a value from a function
  • Next by thread: Re: Returning a value from a function
  • Index(es):
    • Date
    • Thread