Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk3 min

Call by Value: What Happens to Arguments Inside a Function

Call by value gives a function a local parameter containing an argument’s evaluated value. Learn why rebinding differs from mutating an object shared with the caller.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Call by value means a function receives an argument’s evaluated value in a local parameter. Assigning a different value to that parameter does not, by itself, replace the caller’s variable. If the copied value refers to a mutable object, however, both caller and function may reach that same object, so a mutation can be visible to the caller.

How call by value works

A function call evaluates its argument expression and supplies the resulting value to a parameter. The parameter is a local name in the function. The caller’s variable and the parameter are distinct: assigning a new value to the parameter changes the local parameter, not the caller’s variable.

As an Amazon Associate I earn from qualifying purchases.

For example, if a caller passes the value 20 to a parameter named x, then the function sets x = 5, the caller’s variable remains unchanged. The GNU C Language Manual describes this as call by value: Function Call Semantics.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why an object can change even when the parameter is passed by value

The value passed to a function may itself be a reference to an object. The function receives a copy of that reference, and the caller’s variable and the local parameter can both refer to the same object. The function can mutate the shared object through its reference; the caller can then observe the changed state. But if the function assigns a different reference to its local parameter, that does not change the caller’s variable.

  • Rebinding: Assigning another value or reference to the parameter changes the local parameter only.
  • Mutation: Changing the state of an object reached through a shared reference can be visible to the caller.

These are different operations. Being able to mutate an object does not mean the function received the caller’s variable itself.

How the idea appears in common languages

C

The GNU C Language Manual explains that a function call evaluates argument expressions, converts the resulting values as required by the function declaration, and runs the function with copies of those converted values. Its example changes a local parameter initialized from the caller’s value; the caller’s variable remains unchanged. Passing a pointer does not change C’s call-by-value rule: the pointer value is copied, and the function can use that copy to access the pointed-to storage.

Python

The Python 3.14.8 glossary defines an argument as a value passed to a function or method and explains that the evaluated value is assigned to the named local variable. See the official Python glossary.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If a function receives a list as items, then items = [] rebinds the local name; it does not replace the caller’s variable. By contrast, items.append("x") mutates the list object. If the caller also refers to that object, it can see the appended item.

Java

Java passes reference-type parameters, including objects, by value: the method receives a copy of the reference. The copied reference initially identifies the same object, so changing an accessible field or calling a mutating method can affect that object. Reassigning the method parameter to a new object does not change which object the caller’s variable refers to. Oracle’s tutorial, written for JDK 8, explains this in Passing Information to a Method or a Constructor.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Call by value versus call by reference

In call by value, a parameter receives the argument’s value. Reassigning the parameter does not directly replace the caller’s variable. With call-by-reference semantics, a function can operate on the caller’s variable itself, so assigning through the parameter can change that variable. These terms describe how parameters relate to caller variables—not simply whether a function can affect data the caller can see.

A shared object can make call-by-value code appear to behave like call by reference: the function mutates the object, and the caller sees the mutation. To tell what happened, ask whether the function changed the shared object or rebound its local parameter.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value

A quick way to analyze a function call

  1. Identify the value produced by the argument expression.
  2. Ask whether that value is a simple value or a reference to an object.
  3. Check whether the function reassigns its parameter or mutates an object reached through it.
  4. Determine what the caller can observe: parameter reassignment alone does not replace the caller’s variable, while mutation of a shared object may be visible.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.