[chuck-users] variable of type function
Atte André Jensen
atte.jensen at gmail.com
Sun Jul 16 09:29:40 EDT 2006
Atte André Jensen wrote:
> Hi
>
> Is it possible to have a variable of type function?
Or clearer, more correctly put: "Is it possible to store the reference
to a function in a variable?"
I'd like to do something like this:
class test{
f function;
fun void set(function new_f){
f @=> new_f;
}
fun void print(){
f();
}
}
fun void print_a(){
<<<"a">>>;
}
fun void print_b(){
<<<"b">>>;
}
test c;
c.set(print_a);
c.f();
//should print "a";
c.set(print_b);
c.f();
//should print "b";
--
peace, love & harmony
Atte
http://www.atte.dk | quartet: http://www.anagrammer.dk
http://www.atte.dk/gps | compositions: http://www.atte.dk/compositions
More information about the chuck-users
mailing list