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

Doubly linked list than by singly linked list, Which operations is performe...

Which operations is performed more efficiently by doubly linked list than by singly linked list Deleting a node whose location is given.

Pushbutton switches, Use the input capture to control the digital clock.  I...

Use the input capture to control the digital clock.  In this part, there will be two switches to control the clock, one is for starting the clock and one is for stopping the clock.

Name some popular internet browsers, Name some Popular Internet Browsers ...

Name some Popular Internet Browsers There are many internet browers are available on internet. Some Popular Internet Browsers are: Internet Explorer, Netscape Navigato

What is a screen group, What is a screen group? How it is useful? Scre...

What is a screen group? How it is useful? Screen group is a field in the Screen Attributes of a screen.  Here we can explain a string of up to four characters which is availa

How to build the structure chart, Building the Structure Chart - Proces...

Building the Structure Chart - Processes in the DFD tend to show single module on the structure chart Afferent processes - give inputs to system Central processes -

Pros and cons of general purpose register architecture, Q. Pros and Cons of...

Q. Pros and Cons of general purpose register architecture? General Purpose Register Architecture: Pros and Cons Registers can be employed to store variables as it decrea

How do you track down a transition by name, Question 1: a) How do you ...

Question 1: a) How do you track down a transition by name? b) Why Premiere Pro is considered a non-linear editor? c) Explain clearly the main problem that may arise wh

Advantages and disadvantages of shared memory programming, Q. Show Advantag...

Q. Show Advantages and Disadvantages of Shared Memory Programming? Advantages of Shared Memory Programming Data sharing between processes is both rapid and uniform bec

Data structure, Process: pid start time end time priority t...

Process: pid start time end time priority timeslice list of CPU bursts list of IO bursts (the number of IO burst will always be 1 less than the number of CPU

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