We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Frame References

Consider this example of Sneklang scopes and stack frames:

msg1 = "This is in scope 1"


def outer_func():
    msg2 = "This is in scope 2"

    def inner_func():
        msg2 = "This is in scope 3"
        return

    return

In scope 2, we add msg2 to its referenced objects. Once again, this is a bit simplified from what you would do in a real, production-grade language, but the idea is the same.

Each stack frame needs to know about all of the objects that it references.

Assignment

Complete the frame_reference_object function in vm.c. It should push the object onto the stack of references for the current frame.