What is the formal difference between an expression and a function? I know the difference by looking at it, but I'm looking for a thorough understanding of it. For example, showing some examples from Scheme or Python:
; scheme
(display "hello") # expression
((lambda () (display "hello"))) # unnamed lambda
(define hi (lambda () (display "hello"))) # named lambda
# python
>>> print ('hello')
>>> lambda: print ('hello')
>>> hi = lambda: print ('hello')
In my rudimentary thinking, I thought the differences are:
- A function has a name and can be referred to (though an expression could be assigned to a variable?)
- A function can take parameters (is an expression able to?)
- A function can have a scope/encapsulation and contain multiple statements.