Before understanding why functions are called first-class citizens in some programming languages and not in others, we need to understand what a first-class citizen means in a programming language.
In programming, a first-class citizen (or first-class object) is an entity that can be treated like any other value in the language.
This means it can:
def greet():
return "Hello"
# 1. Assigned to a variable
say_hello = greet
# 2. Passed as an argument
def call_func(func):
print(func())
call_func(say_hello)
# 3. Returned from a function
def outer():
return greet
inner = outer()
print(inner())
Here, functions are first-class citizens because they can be assigned, passed, and returned.
✅ Primitive types (int, float, char)
✅ Pointers (including function pointers)
⚠️ Functions are not fully first-class — you can use function pointers, but no closures or nested functions.
→ First-class citizens: Variables, pointers, primitive types