16 Jul
2006
16 Jul
'06
9:29 a.m.
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