Computer Science Canada

Passing functions as parameters

Author:  smool [ Mon Mar 05, 2012 5:08 pm ]
Post subject:  Passing functions as parameters

Is it possible? If so, how Question

Author:  Tony [ Mon Mar 05, 2012 5:26 pm ]
Post subject:  RE:Passing functions as parameters

function pointers. Take a look at GUI module implementation for an example (you pass pointers to functions to buttons on creation, so that buttons know what functions to call when pressed).

Author:  Raknarg [ Mon Mar 05, 2012 6:46 pm ]
Post subject:  RE:Passing functions as parameters

Out of curiosity, how would you create a function pointer?

Author:  chrisbrown [ Mon Mar 05, 2012 7:09 pm ]
Post subject:  Re: Passing functions as parameters

Turing:
fcn foo(x : int) : int
    result x + 1
end foo

var fooPtr : fcn f(n : int) : int

fooPtr := foo

put fooPtr(0)

Author:  smool [ Mon Mar 05, 2012 8:29 pm ]
Post subject:  RE:Passing functions as parameters

Sweet, thanks.

Author:  Raknarg [ Mon Mar 05, 2012 8:41 pm ]
Post subject:  RE:Passing functions as parameters

Thanks, +1 karma
Aw yeah, variable procedures and functions. This is useful Smile


: