COMPSCI 61A Lecture 5: CS 61A LEC 05
zogo39484755 and 6 others unlocked
22
COMPSCI 61A Full Course Notes
Verified Note
22 documents
Document Summary
Environment diagrams already handle the case of higher-order functions. When a function is defined inside another function, it is not assigned to a value until the parent function is called. Returning a function assigns the function to a name in the global frame. However when that function is called in the global frame, its parent is still the frame of the function where it was created. The parent of a function is the current frame when that function is created. Allows you to establish a proper environment for when the function is called. Every-user defined function has a parent frame (often global) Create a function value: func () [parent=] Bind to the function value in the current frame. Add a local frame, titled with the of the function being called. Copy the parent of the function into the local frame: [parent=] Bind the to the arguments in the local frame.