Learntofish's Blog

A blog about math, physics and computer science

Posts Tagged ‘call by object reference’

Call by Object Reference (Call by Sharing)

Posted by Ed on January 9, 2012

In the following I want to talk about Call by Object Reference also known as Call by Sharing. I will use Python to illustrate the concept.

1. Strange behavior?

Let’s have a look at the following Python code:

def changeList1(x):
    x.append(41)

def changeList2(x):
    x = [41,42]

Save the code in a file callBySharing.py and run it in Read the rest of this entry »

Posted in computer science | Tagged: , , | 1 Comment »