Is there a way to keep that funktion in memory for the duration of the calling program?
No. AFAIK the only way is to put the functions inside the same script file. Use procedures, like this:
/**/
say moo('test','foo')
exit
moo: procedure
say 'numargs:' arg() 'args:' arg(1) arg(2)
return 'moo ' || arg(1) || ' [' || arg(2) || '] !'