일급 객체 , 일급함수

https://ko.wikipedia.org/wiki/일급_객체

image.png

(cited from fluent python , 311)

클로저는 함수인가 스코프인가?

A closure in programming is not just a function or just a scope—it is actually a combination of both. It fundamentally consists of a function bundled together with a referencing environment for the free variables necessary to support that function. Here’s how that breaks down:

Function

The core of a closure is a function—it has parameters and a body, just like any typical function you might define. What differentiates a closure functionally is its ability to access variables that are not passed in as parameters but are instead captured from the surrounding scope where the closure was defined.

Referencing Environment

The other crucial component of a closure is the referencing environment (or the closure's "scope"). This environment includes any local variables that were in-scope at the time the closure was created and which are used within the closure. This environment travels with the closure, meaning that the closure can be executed in a different context (e.g., in another function or as a callback) and still retain access to these captured variables.

How It Works Together