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

Describe about the database marketing application of olap, Database marketi...

Database marketing tool or application helps a user or marketing professional in determining the right tool or plan for his valuable add campaign. This tool haves data from all sou

Describe the bespoke versus off-the-shelf software, Bespoke versus off-the-...

Bespoke versus off-the-shelf software Generally software packages are bought off-the-shelf. Though, certain applications (generally for industrial companies, commercial busines

What is sap luw or update transaction, What is SAP LUW or Update Transactio...

What is SAP LUW or Update Transaction? Update transaction (or "SAP LUW") This is a set of updates terminated by an ABAP/4 commit.  A SAP LUW may last much longer than a data

Define cache line, Define cache line. Cache block is used to refer to a...

Define cache line. Cache block is used to refer to a set of contiguous address location of some size. Cache block is also referred to as cache line.

DFD, Draw the Context level DFD for the Safe home Software.

Draw the Context level DFD for the Safe home Software.

What is incidence matrix, Incidence Matrix: - This is the incidence matrix ...

Incidence Matrix: - This is the incidence matrix for an undirected group. For directed graphs, the vertex from where an edge is originating will have +1 and the vertex where the ed

Functional units of a computer system, Functional units of a computer syste...

Functional units of a computer system: Digital computer systems consist of 3 distinct units. These units are as follows:  Central Processing unit Input unit and Output unit.

Branding choices, Develop a web traffic plan - suppose that there is no/min...

Develop a web traffic plan - suppose that there is no/minimal advertising budget so you will require to look at branding choices & site design, word-of-mouth and publicity as your

What is precloud computing, What is precloud computing? Precloud comput...

What is precloud computing? Precloud computing is an email access was through a single computer, which also keeps all email messages. Example: Microsoft Outlook or Outlook Expr

Pros and cons of assembly language, Pros and Cons of Assembly Language ...

Pros and Cons of Assembly Language The following are a number of advantages / disadvantages of employing assembly language: Assembly Language offers more control over ha

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