Author |
Message |
smool

|
Posted: Mon Mar 05, 2012 5:08 pm Post subject: Passing functions as parameters |
|
|
Is it possible? If so, how  |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Tony

|
Posted: 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). |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
Raknarg

|
Posted: Mon Mar 05, 2012 6:46 pm Post subject: RE:Passing functions as parameters |
|
|
Out of curiosity, how would you create a function pointer? |
|
|
|
|
 |
chrisbrown

|
Posted: 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) |
|
|
|
|
|
 |
smool

|
Posted: Mon Mar 05, 2012 8:29 pm Post subject: RE:Passing functions as parameters |
|
|
Sweet, thanks. |
|
|
|
|
 |
Raknarg

|
Posted: 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  |
|
|
|
|
 |
|