Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Passing functions as parameters
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
smool




PostPosted: Mon Mar 05, 2012 5:08 pm   Post subject: Passing functions as parameters

Is it possible? If so, how Question
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: 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).
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Raknarg




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




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




PostPosted: Mon Mar 05, 2012 8:29 pm   Post subject: RE:Passing functions as parameters

Sweet, thanks.
Raknarg




PostPosted: 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
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: