Parameter-Passing Methods
Parameter-passing semantics decide whether a callee receives a copy, an alias, or a copy-in/copy-out proxy for the caller's data.
The key question is what exactly crosses the call boundary.
Sebesta treats parameter passing as one of the deepest subprogram design decisions because it controls aliasing, side effects, and how much a callee can change the caller's state.
When to reach for this
Reach for this concept when you want to predict whether a subprogram can mutate caller data, whether two parameter names can alias the same storage, or why one language's function call behaves differently from another's.
Why this matters
A function call can look innocent in source code while hiding important memory behavior. Understanding pass-by-value, pass-by-reference, and value-result semantics explains many surprising bugs.
The mental model
Copies isolate the callee
If the callee receives its own slot, local changes do not automatically leak back to the caller.
Aliases couple caller and callee
If the callee receives another name for the same storage, side effects become immediate and visible outside the routine.
Step through the concept
How to use this page
Follow the animation one state at a time and connect the code to the runtime behavior.
- Keep the caller value in view and compare it to the callee parameter on every step.
- Notice which tabs create a copy and which create an alias.
- Watch for the copy-out step because it is the entire point of value-result semantics.
Caller owns score = 10.
Copies the argument into a local slot
void boost(int n) {
n = n + 5;
}
int score = 10;
boost(score);Each passing strategy answers the aliasing question differently
| Aspect | Pass by value | Pass by reference | Value-result |
|---|---|---|---|
| What enters the callee | A copied value | An alias to caller storage | A copied value |
| When caller sees changes | Never | Immediately | At return |
| Main benefit | Isolation | Direct mutation | Isolation during call, update after |
| Main risk | Extra copying | Aliasing surprises | Copy-out surprises with shared targets |
The short version
- Parameter passing is a memory model decision, not just a syntax choice.
- Pass by value protects the caller by isolating the callee in a copied slot.
- Pass by reference exposes the caller slot directly, so side effects are immediate.
- Value-result copies in first and copies out later, which changes when the caller sees updates.