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

Mating - canonical genetic algorithm, Mating: Therefore once our GA ag...

Mating: Therefore once our GA agent has chosen the individuals lucky sufficient as actually there  fit enough to produce offspring then we next determine how they are going to

Add the equation by using 2's compliment, Add 20 and (-15) using 2's comple...

Add 20 and (-15) using 2's complement ? Ans. Addition of 20 and (-15) by using 2's complement as (20) 10 = 1 0 1 0 0                                                  (16

Use of arrays in assembly, An array is referencing using a base array value...

An array is referencing using a base array value as well as an index. To simplify addressing in arrays 8086 has provided two index registers for mathematical computations viz. BP a

Computer graphics, What is intractive graphics and user dialouge in comput...

What is intractive graphics and user dialouge in computer graphics

Computer systems architecture, Assume that you are working in a software co...

Assume that you are working in a software company as a programmer and a bank is your company's client. The Bank is a most popular and one of the leading banks in Malaysia. Your

Micooperation, please suggest me ,how to write microopertions,and study for...

please suggest me ,how to write microopertions,and study for computer architecture

Asymptotic notations, Asymptotic Notations These notations are used fo...

Asymptotic Notations These notations are used for evaluating functions. Assume we have two functions f(n) and g(n) defined on real numbers, Theta Notation Big Notation

Differentiate between EPROM and EEPROM, Differentiate between EPROM and EEP...

Differentiate between EPROM and EEPROM. EPROM: The meaning of this term is Erasable PROM. This can be reprogrammed through first erasing the existing program. EPROM uses N-MO

How debugger works internally, Whenever we compile with -g option, it will ...

Whenever we compile with -g option, it will make a symbol table, and according that table for every function and line it will call ptrace.

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