Class: func

Sk.builtin. func

new func(code, globalsopt, closureopt, closure2opt)

This function converts a Javascript function into a Python object that is callable. Or just think of it as a Python function rather than a Javascript function now. This is an important distinction in skulpt because once you have Python function you cannot just call it. You must now use Sk.misceval.callsim to call the Python function.

Name Type Attributes Description
code function

the javascript implementation of this function

globals Object <optional>

the globals where this function was defined. Can be undefined (which will be stored as null) for builtins. (is that ok?)

closure Object <optional>

dict of free variables

closure2 Object <optional>

another dict of free variables that will be merged into 'closure'. there's 2 to simplify generated code (one is $free, the other is $cell)

closure is the cell variables from the parent scope that we need to close over. closure2 is the free variables in the parent scope that we also might need to access.

NOTE: co_varnames and co_name are defined by compiled code only, so we have to access them via dict-style lookup for closure.