Intermediate Compilers & Programming Language Theory
Q55 / 100

What is the difference between call-by-value, call-by-reference, and call-by-need?

Correct! Well done.

Incorrect.

The correct answer is B) Call-by-value: evaluate argument before call; by-reference: pass the location; by-need (lazy): evaluate argument only when needed, at most once

B

Correct Answer

Call-by-value: evaluate argument before call; by-reference: pass the location; by-need (lazy): evaluate argument only when needed, at most once

Explanation

CBV (C, Java, Rust): argument evaluated before function call. CBR (C++ &, pass address): modifications affect caller. CBN/CBNeed (Haskell): evaluate when needed, memoize result. Lazy evaluation enables infinite lists but makes space analysis harder.

Progress
55/100