0
0
Compiler Designknowledge~5 mins

Parameter passing mechanisms in Compiler Design - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is pass by value in parameter passing?
Pass by value means the function receives a copy of the argument's value. Changes inside the function do not affect the original variable.
Click to reveal answer
beginner
Explain pass by reference.
Pass by reference means the function receives a reference (or address) to the original variable. Changes inside the function affect the original variable.
Click to reveal answer
intermediate
What is the difference between pass by value and pass by reference?
Pass by value sends a copy of data, so changes don't affect the original. Pass by reference sends the actual location, so changes affect the original variable.
Click to reveal answer
intermediate
What does pass by value-result mean?
Pass by value-result copies the argument's value to the function (like pass by value) and then copies it back to the original variable after the function finishes.
Click to reveal answer
advanced
Describe pass by name parameter passing.
Pass by name delays evaluation of the argument until it is used inside the function, substituting the argument expression directly. It behaves like textual substitution.
Click to reveal answer
Which parameter passing mechanism allows the function to modify the caller's variable directly?
APass by value-result
BPass by reference
CPass by value
DPass by name
In which parameter passing method is the argument evaluated only when used inside the function?
APass by value
BPass by value-result
CPass by reference
DPass by name
What happens to the original variable in pass by value-result after the function finishes?
AIt is updated with the function's local copy
BIt is passed by reference
CIt is deleted
DIt remains unchanged
Which parameter passing mechanism is safest to avoid unintended side effects?
APass by name
BPass by reference
CPass by value
DPass by value-result
Which mechanism can cause unexpected behavior due to multiple evaluations of the argument?
APass by name
BPass by reference
CPass by value
DPass by value-result
Explain the main differences between pass by value and pass by reference with examples.
Think about whether the function can change the caller's variable.
You got /4 concepts.
    Describe pass by value-result and pass by name, and discuss when each might be useful.
    Consider copying values vs delaying evaluation.
    You got /4 concepts.