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

Differentiate between intranet and internet, Differentiate between intranet...

Differentiate between intranet and internet Some comparisons between intranet and internet include: -  INTERNET is INTERnational NETwork -  An INTRANET is INTernal Restri

What is the prominence of rs232-c in serial communication, What is the prom...

What is the prominence of RS232-C in serial communication?  Name some application where you see its use.  RS-232 stands for Recommend Standard number 232 and C is the latest re

What is central processing unit, What is Central Processing Unit Centra...

What is Central Processing Unit Central Processing Unit (CPU) performs all the arithmetic and logical calculations in a computer. The CPU is said to be the brain of the compute

Input output in assembly program, Q. Input output in assembly program? ...

Q. Input output in assembly program? Software interrupt is a call to an Interrupt servicing program situated in the operating system. Generally the input-output routine in 8086

Tightly coupled system- shared memory system, Tightly Coupled System- Share...

Tightly Coupled System- Shared Memory System Shared memory multiprocessorshas has following description: Every processor commune through a shared global memory. For

Summary of tasks, Summary of Tasks Task Summary attempts to show amoun...

Summary of Tasks Task Summary attempts to show amount of duration every task has spent starting from beginning of task until its completion on any processor as displayed in Fi

By which analog signal combine with a carrier frequency, Analog signals can...

Analog signals can be              by combining them with a carrier frequency (A)  Carried                                      (B)  Transported (C)  Multiplexed

Illustrate the benefits of functional model, Illustrate the benefits of Fun...

Illustrate the benefits of Functional model Functional model shows how values are computed. This model describes decisions or object structure without regard for sequencing. I

Describe key features of the von neumann architecture, Q. Describe key feat...

Q. Describe key features of the von Neumann Architecture? Describe key features of the von Neumann Architecture: The mainly basic function performed by a computer is exe

Write a program to event advertised, A museum has a collection of old poste...

A museum has a collection of old posters advertising events of various kinds (theatre, sport, fairs, lectures etc.). It wishes to keep a record of these, containing, for each poste

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