Function abstracts a sequence of behaviors as its signature

By treating a function as a protocol, we can achieve modular programming
- Alice writes the main function (caller) and requires a module consisting of specific behaviors
- Alice delegates Bob to implement a function (callee) that defines these behaviors (Function body)
- To collaborate, To collaborate, Alice and Bob agree on the inputs (parameters) needed for the callee and the output (return value). These parameters and return value can be seen as an interface.
Call Stack (x86)
- A function involves its local variables, parameters, and return value
- These are stored and managed in the call stack
- Each thread has its dedicated stack whose size is 1MB (by default)
- A call stack consists of stack frames
When a function is called, its corresponding stack frame is created and pushed onto stack
- Local variables are pushed into stack in declaration order
- An array is pushed into stack from its last element
- parameters are pushed into stack from left to rights
- etc …

Calling Convention
