Give examples of different parameter-passing mechanisms, Computer Engineering

Assignment Help:

Explain different parameter passing mechanisms to a function with the help of example?

The different parameter-passing mechanisms are given below:

1.   Call by value

2.   Call by value-result

3.   Call by reference

4.   Call by name

In first call by value mechanism, the values of real parameters are passed to the called function. These values are allocated to the consequent formal parameters. If a function changes the value of a formal parameter, the modification is not reflected upon the consequent actual parameter. It is commonly utilized for built-in functions of the language. Its major advantage is its simplicity. The compiler can use formal parameter like a local variable. It simplifies compilation considerably.

Call by value-result: This mechanism extends the abilities of the call by value mechanism through copying the values of formal parameters back in consequent actual parameters at return. Such mechanism inherits the simplicity of the first mechanism i.e. but incurs higher overheads.

Call by reference: Now the address of an actual parameter is passed to the called function. If the parameter is an expression, its value is calculated and stored in a temporary location and the address of the temporary location is passed to the called function. If the parameter is an array component, its address is likewise calculated at the time of call. Such mechanism is very popular since this has 'cleaner' semantics than call by value-result.

Call by name: Such parameter transmission mechanism has similar effect as if every occurrence of a formal parameter in the body of the called function is replaced through the name of the consequent actual parameter. The actual parameter consequent to a formal parameter can change dynamically throughout the execution of a function. It makes the call through name mechanism immensely powerful. Though, the high overheads make this less attractive in practice.


Related Discussions:- Give examples of different parameter-passing mechanisms

Unification algorithm - artificial intelligence, Unification Algorithm - Ar...

Unification Algorithm - Artificial intelligence: To merge two statements, we should get a substitution which forms the two sentences similar. Remember that we write V/T to sign

Create new user account - system administrator, A common task for a system ...

A common task for a system administrator is to create new user accounts. In this lab you will be creating output that looks like an /etc/passwd file. The Problem You are to

What is the best way offload responsibility, What is the best way offload r...

What is the best way offload responsibility? The best way to offload responsibilities is to purchase services through a Service Provider. ISPs, customers and Service Provide

Variable or compound expression - unification algorithm, Variable or compou...

Variable or compound expression - Unification algorithm: Here some things to note regarding this method are:  (i) There if really trying to match a constant to a different

Explain the fixed logic versus programmable logic, Explain the Fixed Logic ...

Explain the Fixed Logic Versus Programmable Logic? The Logic devices can be classified into two broad categories - fixed and programmable. The same as the name suggests, the ci

What is preemptive and nonpreemptive scheduling, What is preemptive and non...

What is preemptive and nonpreemptive scheduling? Under nonpreemptive scheduling once the CPU has been allocated to a process, the process keeps the CPU unless it releases the C

Discuss the mount and unmount system calls, Discuss the mount and unmount s...

Discuss the mount and unmount system calls. The privileged mount system call is used to join a file system to a directory of another file system; the unmount system call detach

Explain classless inter-domain routing, Explain Classless Inter-Domain Rout...

Explain Classless Inter-Domain Routing. It is a new addressing scheme for the internet that permits for more efficient allocation of IP addresses than old class A, B and C addr

Difference between static and dynamic RAM, Difference between static and dy...

Difference between static and dynamic RAM. Draw the circuits of one cell of each and explain its working. Ans: Differentiation among Static RAM and Dynamic RAM: Static

Can a structure be used within a structure, Can a structure be used within ...

Can a structure be used within a structure? Yes , a structure can be used within a structure known as nesting of structures.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd