Re: call selector @"mySelector"
Re: call selector @"mySelector"
- Subject: Re: call selector @"mySelector"
- From: Raffael Cavallaro <email@hidden>
- Date: Mon, 3 Oct 2005 09:41:54 -0400
On Oct 3, 2005, at 12:39 AM, Tom Harrington wrote:
Having a variable number of
arguments carries the implication that the number of arguments is not
known in advance. That's not implicit in simply stating that a method
has "any number of arguments".
The phrase "any number of arguments" can mean (among other things) 1.
any *fixed* number of arguments, 2. any number of arguments period. A
good definition of a function that takes a variable number of
arguments is that it takes "any number of arguments." Especially in
the context of a discussion about determining a method where the
selector, target, and arguments are *unknown* at compile time it is
at best unclear, at worst downright misleading to state that we have
a mechanism which can deal with "any number of arguments" when, in
fact, it can only deal with methods of fixed, not variable arity.
We're dealing here with the field of dynamic languages since the
whole discussion involves calling a method that is unknown at compile
time. It pays here to look around to other dynamic languages and
realize that a mechanism to dynamically call methods/functions with a
variable number of arguments is commonplace among other dynamic
languages. That it is missing from the message passing object system
of Cocoa and must be hacked by invoking the internals of the runtime
implementation directly in c, *against* the specific advice of Apple
[1], is an important thing to know if one is constructing calls
dynamically.
Again, my only point was to make clear that the methods provided by
NSObject and NSInvocation are lacking in this respect something that
is important to know when one dealing with methods whose arity will
only be known at runtime.
[1]<http://developer.apple.com/documentation/Cocoa/Conceptual/
ObjectiveC/LanguageOverview/chapter_3_section_6.html>
"Note: The compiler generates calls to the messaging function. You
should never call it directly in the code you write."
regards
Raffael Cavallaro, Ph.D.
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden