

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: Handling Cycles
incomplete
2: Pros and Cons
incomplete
3: Stack Frames
incomplete
4: Tracking Objects
incomplete
5: Free
incomplete
6: Frame References
incomplete
7: Mark and Sweep
incomplete
8: Mark
incomplete
9: Trace
incomplete
10: Sweep
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
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.
Complete the frame_reference_object function in vm.c. It should push the object onto the stack of references for the current frame.