"""
argument reference passing
When the object referenced is immutable,
this is the way references work when arguments are passed to function parameters
Later we will see that references are handled differently when the object referenced is mutable.
"""

# Now consider how arguments are passed to functions.
# The way references are assigned is somewhat different than using the assignment operator
# But the way the references work is very much the same

def fn1(parm1) :
    print("fn1 function execution begins")
    print("parm1 initial value:", parm1)
    # parm1 refers to the same object as arg1
    print( "parm1 id initial value:", id(parm1) )  # result: 1356159296 
    parm1 = parm1 + 1
    print("parm1 value after change: ", parm1)     #5
    # parm1 now refers to a different object
    print( "parm1 id after change: ", id(parm1) )  # result: 1356159312
    print("fn1 function execution ends and execution returns to the main code")

print("The program starts here")
arg1 = 4     # sets arg1 to reference the int object with a value of 4

print("arg1 before the function call:", arg1)     # resust: 4
print( "arg1 id before the function call:", id(arg1) )     # result: 1356159296

# call to the function fn1 passing arg1 as the argument
fn1(arg1)

print("arg1 value after the function call:", arg1)     # resust: 4
print( "arg1 id after the function call:", id(arg1) )     # result: 1356159296 still original result

"""
Result summary:
The program starts here
arg1 before the function call: 4
arg1 id before the function call: 1356159296
fn1 function execution begins
parm1 initial value: 4
parm1 id initial value: 1356159296
parm1 value after change:  5
parm1 id after change:  1356159312
fn1 function execution ends and execution returns to the main code
arg1 value after the function call: 4
arg1 id after the function call: 1356159296
"""