Issues in the Pass by Value

Learn the shortcomings of the pass by value strategy.

Introduction

Pass by value is neat and easy! It does the job perfectly if we need to pass some information for the called function to read.

Pass by value works by creating copies of the arguments and then passing those copies to the called function.

Having to create a copy introduces two drawbacks. We will discuss them now.

Changing the arguments

The first drawback is that we can not propagate the changes from the called function (callee) to the caller. We already saw this in the previous lesson.

Too many copies

The second drawback is more subtle. Even if the code works fine, it may not be ...