Author |
Message |
smool
![](http://compsci.ca/v3/uploads/user_avatars/19584221104f5399411b2b3.jpg)
|
Posted: Mon Mar 05, 2012 5:08 pm Post subject: Passing functions as parameters |
|
|
Is it possible? If so, how ![Question Question](http://compsci.ca/v3/images/smiles/icon_question.gif) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
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. |
|
|
|
![](images/spacer.gif) |
Raknarg
![](http://compsci.ca/v3/uploads/user_avatars/3745510004d8be6689b92f.jpg)
|
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? |
|
|
|
|
![](images/spacer.gif) |
chrisbrown
![](http://compsci.ca/v3/uploads/user_avatars/18814724584bcbb8192aae8.png)
|
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) |
|
|
|
|
|
![](images/spacer.gif) |
smool
![](http://compsci.ca/v3/uploads/user_avatars/19584221104f5399411b2b3.jpg)
|
Posted: Mon Mar 05, 2012 8:29 pm Post subject: RE:Passing functions as parameters |
|
|
Sweet, thanks. |
|
|
|
|
![](images/spacer.gif) |
Raknarg
![](http://compsci.ca/v3/uploads/user_avatars/3745510004d8be6689b92f.jpg)
|
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 ![Smile Smile](http://compsci.ca/v3/images/smiles/icon_smile.gif) |
|
|
|
|
![](images/spacer.gif) |
|