Closures in JS, Python

Posted on October 2, 2021
Tags: javascript

1 Lambda

\[\lambda x. funcbody\]

“lambda x” is a binder whose scope is “funcbody”. An occurance of variable x is bound when it occus in “funcbody” of a “lambda x. funcbody”

def f(b): #stackframe
  b = 4
  return ..
b = 6  #globalscope
def f(b_frame1): 
  b_frame1 = 4
  return ..
b = 6  #globalscope
frames            objects
---
globalframe 
b ------------>     6
---
f frame
b ------------>     4
---