Pass functions

Add functionality to pass functions from scripting back to C++ (e.g., to return callback functions from scripting that can be called later from the C++ code).