PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, no array or string given in /am/paramount/vol/ecs/sites/whiley/wp-includes/class-wp-hook.php on line 298


  • No categories


Whiley supports first-class functions similar those found in languages like [[Python (programming language)|Python]] and [[JavaScript]], and to function pointers in C.  The following illustrates the syntax:

int f1(int x):
    return x + 1

int f2(int x):
    return x * 2

int g(int(int) func):
    return func(1234)

void ::main(System.Console console):

Here, we see that function g() accepts a parameter func of function type.  To generate values of function type, we use the “address-of” operator &.  The parameter func can be invoked inside g() as though it were a normal function.