• 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: Parameter lists
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Parameter lists


  • Subject: Re: Parameter lists
  • From: Ben Dougall <email@hidden>
  • Date: Sat, 8 Nov 2003 02:07:29 +0000

On Saturday, November 8, 2003, at 01:02 am, John MacMullin wrote:

Then why is it referenced in the Objective-C Pocket Reference by Duncan? (At page 18).

John

it depends if the method was written in the first place to take variable parameters or not. some are, some aren't and it's completely up to you with your methods that you write, but not with pre-written methods. put it this way: can you call the strcmp() c function with a comma separated variable parameters list? no, because it was not defined / declared so - with the ... as the last parameter that is. can you call printf with a variable parameter list? yes, because it was written that way. same goes for objective-c. the method has to be written defining that it takes a variable parameter list to allow it to take a variable list. you can't just decide to call a method or function that was not defined to take a variable parameter list with a call containing comma seperated parameters.





On Friday, November 7, 2003, at 03:55 PM, Alastair Houghton wrote:

On 7 Nov 2003, at 22:47, John MacMullin wrote:

With that reflection let us turn to the merits of my comment, which again, was not intended to insult Apple or anyone else.

I don't think anyone assumed that it was. We're just a bit surprised at what you wrote.

My original code came from the Objective C Pocket Reference by Duncan and and the C Programming Language by K and R. Placing multiple parameters in a function (or method) separated by commas is the ordinary c approach. Others on the cocoa list, and in the Apple doc, had stated that support for the ordinary c language is part of Cocoa.

I think you've got the wrong end of the stick.

Support for the ordinary C language is part of Objective-C. Cocoa is just a set of frameworks you can use with Objective-C. Methods, since they are not a part of the C language, use Objective-C syntax, which uses colons rather than commas, primarily because it supports named arguments (a single colon with no name is just an argument with a blank name).

Some methods do, in fact, use commas, but only if they take a variable number of arguments (e.g. NSString's +stringWithFormat: method); this does seem somewhat inconsistent, and is probably an artefact of the original implementation of Objective-C.

Accordingly, it just seems to me that this approach should be supported in Cocoa.

It is, for C functions. But Objective-C isn't part of C (rather, the other way around).

Kind regards,

Alastair.
_______________________________________________
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.
_______________________________________________
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.

References: 
 >Re: Parameter lists (From: John MacMullin <email@hidden>)

  • Prev by Date: (no subject)
  • Next by Date: Re: Parameter lists
  • Previous by thread: Re: Parameter lists
  • Next by thread: Re: Parameter lists
  • Index(es):
    • Date
    • Thread