slang-users mailing list

[2004 Date Index] [2004 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [slang-users] Accessing Functions using an array


> 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]