calling context functions indirectly
Posted: Wed Nov 08, 2006 5:38 pm
What I'm trying to do here is pass functions and contexts around, but I can't get the functions to execute.
The required output is for all available contexts to run their functions when called upon to do so. eval should be able to execute the function...?
Code: Select all
(context 'TEST0)
(define (TEST0:foo)
(println "hi there from TEST0:foo"))
(define (TEST0:bar)
(println "hi there from TEST0:bar"))
(context 'TEST1)
(define (TEST1:foo)
(println "hi there from TEST1:foo"))
(define (TEST1:bar)
(println "hi there from TEST1:bar"))
(context 'TEST2)
(define (TEST2:foo)
(println "hi there from TEST2:foo"))
(define (TEST2:bar)
(println "hi there from TEST2:bar"))
(context MAIN)
(set 'contexts '(TEST0 TEST1 TEST2))
(set 'functions '({foo} {bar}))
(dolist (c contexts)
(map (fn (f) (eval (sym f c))) functions) ; <- doesn't do what I thought it might :-)
)