- Subject: Re: [slang-users] Accessing Functions using an array
- From: Michael Noble <mnoble@xxxxxxxxxxxxx>
- Date: Wed, 22 Dec 2004 15:35:58 -0500
> Is it possible and how would you do it, to set up an
> array that contains function names (slang, not C)
> like such (pseudo code below):
>
> define functioname_1 { .....}
> define functioname_2 { .....}
> define functioname_3 { .....}
You probably want function references, not function names.
In which case something like
MyArray = [&functionname_1, &functionname_2, ...];
should suffice.
There is a catch, however. In SLang 1 there exists a bug
which prevents using the natural idiom
(@MyArray[i]) (...);
to invoke the i-th function within the array. Instead, one must
use a temporary variable to store the function reference, then
deref the variable to invoke the function, along the lines of
variable func = MyArray[i];
(@func) (...);
HTH,
Mike
_______________________________________________
To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html
[2004 date index]
[2004 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]