(context 'NCR)
(set 'ncfuncs '("initscr" "box"))
(define (import-ncurses)
(set 'ctx (context)) ; save callers context
(context 'NCR) ; set translation/import context to NCR
(dolist (x ncfuncs) (import "/lib/libncurses.so.5" x))
(context ctx) ; switch back to calling context
)
(context 'MAIN)
(NCR:import-ncurses) ; all imports will be created in NCR
(NCR:initscr ...) ; uses the functions
You where thinking in the right directtion in your code, trying to set the context before the 'import' statement. But when you call '(NCR:import-ncurses)' from MAIN then the code executing in NCR will also execute from MAIN, but all symbols inside NCR where created when loading the NCR file in NCR. The context set with (context ...) will set the context to use when creating symbols via 'import', 'sym' 'load' etc., but you context of execution still is the one when you called the function.