# Operational Semantics of Function Call
(part of [CC2021](https://github.com/alexhkurz/compiler-construction-2021/blob/master/README.md))
Let us start quoting from the book, which gives the operational semantics for function call assuming that functions do not access global variables.

(Btw, in $f(a_1 , ... ,a_n)$ the $n$ should be an $m$.)
**Question:** How should the rule be modified, if the function $f$ is allowed to access global variables?
In the lecture we came to the following conclusions:
1. the $\gamma$ in $\gamma.x_1:=v_1$ should be a $\gamma_m$
2. the $\gamma′$ should be a $\gamma′.\delta$ (see next item)
3. the $\langle v,\gamma_m\rangle$ should be a $\langle v,\gamma'\rangle$
Wrt item 1, to test whether $\gamma_m$ or $\gamma$ is correct, I propose the following program
```cpp=
#include <stdio.h>
int x = 10;
int f (int y) {
return ++x;
}
int main () {
printf("the value of x is %d\n",x);
printf("the value of f(++x) is %d\n",f(++x));
printf("the value of x is %d\n",x);
}
```
**Homework:**
- Use the program above to find out the correct rule for function call.
- What would you expect to happen if you replaced the `y` in line 5 by an `x`? Run the experiment and check whether the results agree with the operational semantics.