Parameter passing values

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/9

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

10 Terms

1
New cards

2 parameter passing methods

call by value and call by reference

2
New cards

call by value

The actual value is passed to the formal parameter(stored in a new local variable on the stack), which acts like a local variable. Changes do not affect the original variable. It s expensive because large data structures are copied. example: Java, Scheme, pascal, C

3
New cards

call by reference(by variable)

a reference to the actual parameter is passed. changes to the formal parameter do affect the actual one(aliasing). 2-way transmission (from and to the procedure)

4
New cards

read only parameter passing

(const or final) prevents modification of the parameter and avoids unnecessary copying

5
New cards

call by result

An uninitialized local variable is passed. its value is copied back to the actual parameter on return. there is no link between the actual and the formal. Con: large copying cost on return.EX: ADA

6
New cards

Call by reference Pros and Cons

Pro: Efficient, supports returning data via parameters

Con: Complicated semantics due to aliasing

7
New cards

Call by value Pros and Cons

Pros: Simpler semantics and referential transparency

Cons: Cannot return data via parameters; copying cost

8
New cards

Call by name

The actual parameter is not evaluated before the call. Instead its text is substituted into the function body

9
New cards

Call by name environment

there must be passed a pair <exp, env> where exp is the unevaluated expression and env ins the environment in which to evaluate it. It s expensive because the environment must be re-evaluated every time the parameter is used . Ex: Algol

10
New cards

Call by name pointers

2 pointers are passed: a pointer to the expression text and a pointer to the static chain(stack environment)