swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Function as an argument


From: Marcus G. Daniels
Subject: Re: Function as an argument
Date: 03 Apr 2000 17:57:45 -0700
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4

>>>>> "AO" == Akiko Ogawa <- RS/GIS lab <address@hidden>> writes:

AO> Please advise whether a function can be passed by another function
AO> as an argument in Objective-C.  If yes, what should the syntax be
AO> like?

Alternatively, you can pass around the SEL type that you get when you
use M(methodName).  Call a SEL with perform:.  Functions will be somewhat
faster.

typedef void (*func_t) (int count, const char **strings);

void
print_strings (int count, const char **strings)
{
  int i;

  printf ("count: %u\n", count);

  for (i = 0; i < count; i++)
    printf ("string[%u]: `%s'\n", i, strings[i]);
}

void
call_func (func_t func, int count, const char **strings)
{
  func (count, strings);
}

int
main (int argc, const char **argv)
{
  call_func (print_strings, argc, argv);
}

/*
Local Variables:
compile-command: "gcc callfunc.c -o callfunc"
End:
*/

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]