함수형 프로그래밍 언어에서 중요한 개념이며,
JavaScript와 Python등에서 Closure와 같은 다양한 디자인패턴을 응용 및 구현하는데 중요한 역할을 한다.

함수형 언어 관련 참고 자료 :
[summary] imperative language, declarative language...
Imperative language란? 프로그래밍 언어는 컴퓨터의 연산을 모방하고 추상화하는 것에서 출발. 때문에 컴퓨터의 구조가 언어 설계에 영향을 미치게 됨. Von noemmen 구조, 튜링머신을 반영한 프로그래밍
ds31x.blogspot.com
first-class object 정의 (or 특성)
일단 정의를 살펴보면 다음과 같음.
first-class object는 다음과 같은 성질을 가진 entity (독립체)임.
- expression 내에서 사용가능해야함. (expression을 구성하는데 사용될 수 있어야 함)
- variable에 assignment가 가능해야함. *
- function 이나 method 호출 등에서 argument로 사용가능해야함. *
- function call의 return value로 사용가능해야함.
위의 네가지 성질의 주요 알파벳을 따서 EVAC 라는 acronym으로도 불림.
First-class objects can be used in
Expressions, as Variables, and as Arguments, and can be returned by function Calls.
프로그래밍 언어에서의 int나 float, string 등의 기본적인 data type이 대표적인 firt-class object이다.
- 특정 type, object, entity, value가 first-class object라면
- function이 이들 기본적인 data type과 비교하여 어떤 차이점 없이 사용가능하다는 점을 의미하는 것이
- 바로 function이 first-class object 라는 것의 의미임 (Christopher Strachey 의 정의에 기반).
- 위의 4가지 성질들로 first-class object가 가져야할 특징을 구체적으로 나타낸 것은 Robin Popplestone 의 정의에 기반함.
Python에서 function은 first-class object.
주의할 점은 imperative programming language에서는 보통 function은 first-class object가 아닌 반면,
functional programming language에서는 function 도 first-class object이다.
Python은 imperative language로 분류되기도 하지만,
function이 first-class object이다.
- Python에서
map이나filter등의 high-order function들이 - arguments로
- iterator객체와
- 해당 iterator의 각 iteration마다 적용할 function을
- 받던 걸 기억할것.
Function이 바로 first-class object을 이용하여
- callback function 패턴이나 다양한 high-order function들이 동작하며,
- closure나 decorator가 가능해짐.
References
https://isaaccomputerscience.org/concepts/prog_func_first_class_objects?examBoard=all&stage=all
Isaac Computer Science
The free online learning platform for GCSE and A level Computer Science students and teachers. Discover our computer science revision and homework questions today.
isaaccomputerscience.org
함수형 프로그래밍이란 ? functional programming?
함수형 프로그래밍 프로그래밍의 여러 종류 중 하나이며, 함수(function)을 이용해 프로그래밍을 하는 것 입니다. => 함수로만 이수어진 프로그램이라고 생각하면 편할 것 같습니다. 함수형 프로그
99geo.tistory.com
1급 객체(first-class object)란?
일급 객체라는 말이 요새는 많이 보편화가 된 것 같습니다. 제가 이 말을 처음 들었던 건 자바스크립트에서였는데, 단순히 자바스크립트에 국한된 개념은 아니더군요. 프로그래밍 언어론 수업
jcsoohwancho.github.io
2023.07.13 - [Python] - [Python] Callback function
[Python] Callback function
Callback Functioncallback function란 다음 두가지에 해당하는 function을 의미한다.다른 function의 argument로 전달되어 특정 event가 발생시 호출이 이루어지는 function을 가르킨다 (사용자가 명시적으로 호출하
ds31x.tistory.com
2023.07.15 - [Python] - [Python] Closure
[Python] Closure
Closuer의 정의Closure의 정의는 다음과 같음. Nested function 으로, 자신의 enclosing scope (= Python에서 non-local scope)의 상태값(lexcical environment의 variable 값, outer context)을기억하고 유지, 변경, 사용할 수 있는
ds31x.tistory.com
2024.11.20 - [Python] - [Py] Higher-order Function (고차함수)
[Py] Higher-order Function (고차함수)
정의 : Higher-order function(고차 함수)란, 다음 조건 중 하나 이상을 충족하는 function를 가리킴:다른 함수를 argument로 받을 수 있는 function다른 함수를 반환할 수 있는 function즉, Higher-order function이란 fu
ds31x.tistory.com
2023.07.07 - [Python] - [Python] lambda expression and map, filter, reduce.
[Python] lambda expression and map, filter, reduce.
Lambda expression (or Lambda Function, Anonymous Function)Python 에서 lambda function (or lambda expression)은 anonymous function(익명함수)를 만드는데 사용됨.function 형태로 code구현의 재사용을 해야하긴 하지만, def문을 이
ds31x.tistory.com
'Python' 카테고리의 다른 글
| [Python] scope와 키워드 global, nonlocal (0) | 2023.07.15 |
|---|---|
| [Python] Nested Function (or Inner Function) (0) | 2023.07.15 |
| [Python] Callback function (0) | 2023.07.13 |
| [Python] overloading, overriding, and special methods (0) | 2023.07.13 |
| [Python] special methods and operator overloading (0) | 2023.07.13 |